[Solved] Is it possible to import 3 tables data into just one Table [closed]


as noted it is a bit vague, but you are also JOINING the tables upside down, as I cannot see the [race ID] being listed in the [runners] table, that would mean you have runners duplicated and the results would not correlate to the runners as there is no relation. I might also be way of mark as you didn’t provide a schema, so I am taking liberty with the table schemas and using something I would expect.

Maybe try something like this

CREATE TABLE [runners 2000-2005] ([Runner ID] INT, [First Name] NVARCHAR(200), [Last Name] NVARCHAR(200), [Other Details] NVARCHAR(500) )
CREATE TABLE [races] ([Race ID] INT, [Race Name] VARCHAR(200), [Race Location] VARCHAR(200))
CREATE TABLE [results] ([Race ID] INT, [Position] INT, [Runner ID] INT)

SELECT 
T1.[Race ID]
, T1.[Race Name]
, T1.[Race Location]

, T2.[Runner ID]
, T2.Position

, T3.[First Name]
, T3.[Last Name]
, T3.[Other Details]

INTO [all race details 2000-2005] /*Remove this line if you just want a query*/
FROM races AS T1
INNER JOIN results AS [T2] ON T2.[Race ID] = T1.[Race ID]
INNER JOIN [runners 2000-2005] AS [T3] ON T3.[Runner ID] = T2.[Runner ID]

SELECT * 
FROM [all race details 2000-2005]

Is use table aliases just to shorten the query, also I find it easier to first select from the table with the most common information or sits on top of the hierarchy, which is the races table in my opinion.

First there is a race, then some finish order to the race and then the details of the runners in the race.

The SELECT...INTO...FROM will create a fresh table, otherwise you can CREATE TABLE...INSERT INTO TABLE.. SELECT up to you.

1

solved Is it possible to import 3 tables data into just one Table [closed]