SQL basic question

Copper Contributor

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

3 Replies
Sorry, but I don't understand your post/question and it seems the post is incomplete.

@JJevans It appears that your homework was formatted slightly differently to the question you posted here.

I would assume something like this:

SQL CONCEPT 1

Please write the result for the following query

Table1

 name
1A
2B
3C

 

Table2 

 name
1B
2C
3D

 

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.namet2.name
1BB
2CC

@SivertSolemWow thank you so much for your insight. Much clearer now.