Skip to content
Advertisement

how to replace ids with names in sql from another table?

I have a table passenger_count

pas1_id pas2_id count
1 6 2
14 37 4

that connects by pas_id with another table passenger:

id name
1 Bruce k
2 George L
3 Li Wo
4 Don Wa

How to replace pas1_id, pas2_id with actual names from passenger table?

This self join query does not work:

Advertisement

Answer

Just join passenger to passenger_count twice.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement