简体   繁体   中英

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

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

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 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM