-1

我想加入两张桌子,但我遇到了问题

这是我的 SQL 语法

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

这是我得到的错误:

#1052 - where 子句中的列 'bookingId' 不明确

4

2 回答 2

1

使用别名b.bookingId = 9

select * from booking as b join 
booking_detail as bd on b.bookingId = bd.bookingId
WHERE b.bookingId = 9 
于 2019-11-07T09:59:12.507 回答
1

对 bookinid 列使用连接和别名,因为该列在两个表中都可用

select * from booking as b join
 booking_detail as bd 
 on b.bookingId = bd.bookingId
  WHERE b.bookingId = 9
于 2019-11-07T09:59:27.040 回答