Forum Discussion
SQL basic question
I was given the following question on basic SQL. Can someone please help me understand this query?
SQL CONCEPT 1 Please write the result for the following query Table1 name 1.
A 2. B 3. C Table2 name 1. B 2. C 3. D Select t1.name, t2.name FROM Table1 t1 INNER JOIN Table2 t2 ON t1.name = t2.name
- olafhelperBronze ContributorSorry, but I don't understand your post/question and it seems the post is incomplete.
- SivertSolemIron Contributor
JJevans It appears that your homework was formatted slightly differently to the question you posted here.
I would assume something like this:
SQL CONCEPT 1Please write the result for the following query
Table1
name 1 A 2 B 3 C Table2
name 1 B 2 C 3 D Query:
Select t1.name, t2.name FROM Table1 t1 INNER JOIN Table2 t2 ON t1.name = t2.name
To answer:
"Select t1.name, t2.name" is the columns we want to receive.
"FROM Table1 t1 INNER JOIN Table2 t2" means we want a combination of the values from Table1 and Table2, using the shorthand t1 and t2 to refer to the tables
"ON t1.name = t2.name" means we combine rows where the name value is equal in both tables, and drop all other values.
This gives the following result table:
(key) t1.name t2.name 1 B B 2 C C - JJevansCopper Contributor
SivertSolemWow thank you so much for your insight. Much clearer now.