简体   繁体   English

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

[英]#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这是我的 SQL 语法

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 #1052 - where 子句中的列 'bookingId' 不明确

use alias for b.bookingId = 9使用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对 bookinid 列使用连接和别名,因为该列在两个表中都可用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 #1052-where子句中的“年”列不明确 - #1052 - Column 'syear' in where clause is ambiguous 错误 1052 (23000):where 子句中的列“course_id”不明确 - ERROR 1052 (23000): Column 'course_id' in where clause is ambiguous 违反完整性约束:1052列和where子句不明确 - Integrity constraint violation: 1052 Column and in where clause is ambiguous 完整性约束违规:1052 where子句中的列'id'不明确 - Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous 错误代码:1052。where子句中的列“ datetime”不明确 - Error Code: 1052. Column 'datetime' in where clause is ambiguous MySQL错误:冲突:1052 where子句不明确的列'created_at' - Mysql error: violation: 1052 Column 'created_at' in where clause is ambiguous' 错误 1052:where 子句中的列“metric_name”不明确 - Error 1052: Column 'metric_name' in where clause is ambiguous MySQL错误#1052 from子句中的列不明确 - MySQL Error #1052 Column in from clause is ambiguous SQLSTATE [23000]:违反完整性约束:1052 where 子句中的列“值”不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'value' in where clause is ambiguous Laravel Eloquent SQLSTATE[23000]:违反完整性约束:1052 列...在 where 子句中不明确 - Laravel Eloquent SQLSTATE[23000]: Integrity constraint violation: 1052 Column ... in where clause is ambiguous
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM