0

I have a table...

col1  | id   | col3|
---------------------
 1    |123   |     |
 2    |456   |     |
 3    |789   |     |

And I have another table...

id  | name |
------------
123 | Tom  |
456 | Kate |
789 | Pork |
101 |Winter|
102 |Roll  |

I want to join the tables together to get a result that looks like this...

col1  | id   | col3| name
----------------------------
 1    |123   |     | Tom
 2    |456   |     | Kate
 3    |789   |     | Pork

Can someone help me please?

Thanks in advance

3 Answers 3

1

If you only want the data where id from one table matches to id at another table then you can do an inner join like this:

SELECT * FROM table1 INNER JOIN table2 ON table2.id = table1.id

If you want all the data from the first table but only matched id data from the second table then you can do this:

SELECT * FROM table1 LEFT JOIN JOIN table2 ON table2.id = table1.id

For more information about Joins you an refer to this link - SQL joins

Sign up to request clarification or add additional context in comments.

Comments

0

use inner join between two tables

select col1,table1.id,col3,name from table1
inner join table2 on table1.id =table2.id

Comments

0

Do the JOIN :

SELECT t1.*, t2.name
FROM table1 t1 INNER JOIN
     table2 t2
     ON t1.id = t2.id;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.