#1052 - Column 'bookingId' in where clause is ambiguous

401 Views Asked by At

I want to join to two table but I got a problem

Here is my SQL syntax

select * from booking as b,
booking_detail as bd 
WHERE bookingId = 9 AND b.bookingId = bd.bookingId

Here is I got error:

# 1052 - Column 'bookingId' in where clause is ambiguous

2

There are 2 best solutions below

0
Fahmi On

use alias for b.bookingId = 9

select * from booking as b join 
booking_detail as bd on b.bookingId = bd.bookingId
WHERE b.bookingId = 9 
0
Zaynul Abadin Tuhin On

use join and alias name for bookinid column because of this column available in both table

select * from booking as b join
 booking_detail as bd 
 on b.bookingId = bd.bookingId
  WHERE b.bookingId = 9