Given the following tables stored in SQL database
Table person
id username phone
1 james 555-666-777
2 gabriel 666-555-777
3 Lucas 222-888-999
4 Marta 555-444-777
Table room_booking
id person_id room time
1 2 A2 13:00
2 4 B5 09:00
3 1 C1 20:00
By only getting the room_booking id number 2
I would like the output to be:
Output table
id username phone
4 Marta 555-444-777
I know INNER JOIN can do the job but I got fields from the table room_booking included with SELECT *.
As others have said, the answer is to not include the unwanted columns. Since you want all of the columns from one table, and none of the columns from the other table, the solution is to use person.*
I include the distinct because given your structure, you’re likely to have more than one booking per person eventually.
Alternate syntax for achieving the same goal…