问题
I've got an assignment to run some SQL queries on a table looking like this:
T1
C1| C2 | C3
x1| y1 | z1
x2| y2 | z2
But I'm not sure how to create the table in SQL.
回答1:
Are you sure is the right way to design the tables?
It look like a simple Master/Detail model
Probably your T1 table is the master
On the second table (C) put a column with reference ID to the main table
The do the query with a simple Join or Left Join
回答2:
You can create your tables using the following query: (Don't forget to have a primary key )
Create table *table 1 name *(
*column 1 name* *properties of the column 1*,
*column 2 name* *properties of the column 2*,
*column 3 name* *properties of the column 3*
)
You can do the same thing with the second table that you nedd to create.
Here there is an example for you:
Create table car(
id int primary key,
name string,
model string
)
来源:https://stackoverflow.com/questions/63446993/creating-tables-with-columns-having-mulitple-values-in-sql