SQLSTATE[23000]: Integrity constraint violation: 1052
this what i got, when i'm trying to query/retrieve with in the 2 tables, and at the end of error statement with ambiguous column from my WHERE clause, here the exact error.
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous (SQL: select `id`, `account_number`, `gateway_alias`, `gateway_id`, `volume`, `gateway_url`, `gateway_user`, `portal_url`, `portal_user`, `company`.`name`, `product` from `mids` inner join `company` on `mids`.`company_id` = `company`.`company_id` where `status` = 1)
since i'm doing inner join here, we need to identify the table source of the columns inside on our WHERE clause, so i done it like this;
return $q->select(
'id', 'account_number', 'gateway_alias', 'gateway_id', 'volume', 'gateway_url', 'gateway_user',
'portal_url', 'portal_user', 'company.name', 'product'
)
->join('company', 'mids.company_id', '=', 'company.company_id' )->where('mids.status', $stat )->get();
NOTE: its a simple Laravel query inside a Model Class
hope this will help! :)
0 comments:
Post a Comment