简体   繁体   English

完整性约束违规:1052 列 'group_id' 在 where 子句不明确

[英]Integrity constraint violation: 1052 Column 'group_id' in where clause is ambiguous

I'm trying to do inner join for groups table and status table but it stated this error:我正在尝试对组表和状态表进行内部连接,但它说明了这个错误:

Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'group_id' in where clause is ambiguous in C:\xampp\xampp\htdocs\mindspace\libs\database.php:27 Stack trace: #0 C:\xampp\xampp\htdocs\mindspace\libs\database.php(27): PDOStatement->execute(Array) #1 C:\xampp\xampp\htdocs\mindspace\Business Services Layer\ManageGroupsModel\GroupsModel.php(36): DB::run('select status.s...', Array) #2 C:\xampp\xampp\htdocs\mindspace\Business Services Layer\ManageGroupsController\GroupsController.php(40): ManageGroupsModel->displayStatus() #3 C:\xampp\xampp\htdocs\mindspace\Application Layer\ManageGroupsView\view_group.php(13): ManageGroupsController->displayStatus('12') #4 {main} thrown in C:\xampp\xampp\htdocs\mindspace\libs\database. Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'group_id' in where clause is ambiguous in C:\xampp\xampp\htdocs\mindspace\libs\database.php:27 Stack trace: #0 C :\xampp\xampp\htdocs\mindspace\libs\database.php(27): PDOStatement->execute(Array) #1 C:\xampp\xampp\htdocs\mindspace\Business Services Layer\ManageGroupsModel\GroupsModel.php(36 ): DB::run('select status.s...', Array) #2 C:\xampp\xampp\htdocs\mindspace\Business Services Layer\ManageGroupsController\GroupsController.php(40): ManageGroupsModel->displayStatus( ) #3 C:\xampp\xampp\htdocs\mindspace\Application Layer\ManageGroupsView\view_group.php(13): ManageGroupsController->displayStatus('12') #4 {main} 在 Z0D61F8370CAD1D412F80B84D143E1257 中抛出\mindspace\libs\数据库。 php on line 27 php 上线 27

function displayStatus() {
  $sql = "select status.status_content, groups.group_name from status inner join groups on status.group_id = groups.group_id  where group_id=:group_id";
  $args = [':group_id'=>$this->group_id];
  return DB::run($sql, $args);
}

Can anyone please help me cause I'm not sure which part did I do wrongly.谁能帮助我,因为我不确定我做错了哪一部分。

You've got two group_id fields in your results.您的结果中有两个group_id字段。 mySQL isn't sure which one you want to test in your WHERE clause. mySQL 不确定您要在WHERE子句中测试哪一个。 You need to specify it using the correct alias (as you've done in the JOIN already).您需要使用正确的别名指定它(就像您在 JOIN 中所做的那样)。

暂无
暂无

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

相关问题 完整性约束违规:1052 where子句中的列'id'不明确 - Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel 完整性约束违规:1052 列 'id' in where 子句不明确 - Laravel Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel 6 错误:SQLSTATE[23000]:违反完整性约束:1052 where 子句中的列“id_perusahaan”不明确 - Laravel 6 Error : SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_perusahaan' in where clause is ambiguous Laravel SQL 错误:违反完整性约束:1052 where 子句中的列“id”不明确 - Laravel SQL Error: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous 违反完整性约束:1052 where子句不明确的列'prof_id'Laravel - Integrity constraint violation: 1052 Column 'prof_id' in where clause is ambiguous Laravel Laravel Eloquent:违反完整性约束:where 子句中的 1052 列“id”不明确 - Laravel Eloquent: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous 如何解决完整性约束违规:1052 列 'id' in where 子句在 laravel 中不明确 - How to solve Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous in laravel 违反完整性约束:1052 order子句中的“位置”列不明确 - Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous Magento问题与外部mod“违反完整性约束:1052 where子句不明确的列'created_at'” - Magento issue with external mod “Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous” SQLSTATE [23000]:完整性约束违规:1052 where子句中的列'status'不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM