Php Mysql select 查询无效
Php Mysql select query not working
以下查询导致以下错误:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'AccountId' in where clause is ambiguous
$select = $this->select()
->from(array('finance_account' => DB_TABLE_PREFIX . 'finance_account'), array(
'AccountId',
'ParentAccountId',
'AccountGroupId',
'AccountPath',
'AccountCode',
'AccountName',
'Description'
))
->joinLeft(array('ac' => DB_TABLE_PREFIX . 'customer'), 'finance_account.AccountId = ac.AccountId', array())
// using "array_unique()" to minimize db overhead
->where('AccountId IN (?)', array_unique($parentIds))
->setIntegrityCheck(false);
我没有任何其他列可以进行连接。我现在该怎么办?
AccountId 像 finance_account.AccountId 或 ac.AccountId 因为查询不明确 table 要查看
$select = $this->select()
->从(数组('finance_account' => DB_TABLE_PREFIX . 'finance_account'), 数组(
'AccountId',
'ParentAccountId',
'AccountGroupId',
'AccountPath',
'AccountCode',
'AccountName',
'Description'
))
->joinLeft(array('ac' => DB_TABLE_PREFIX . 'customer'), 'finance_account.AccountId = ac.AccountId', array())
// 使用 "array_unique()" 来最小化数据库开销
->where('ac.AccountId IN (?)', array_unique($parentIds))
->setIntegrityCheck(false);
以下查询导致以下错误:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'AccountId' in where clause is ambiguous
$select = $this->select()
->from(array('finance_account' => DB_TABLE_PREFIX . 'finance_account'), array(
'AccountId',
'ParentAccountId',
'AccountGroupId',
'AccountPath',
'AccountCode',
'AccountName',
'Description'
))
->joinLeft(array('ac' => DB_TABLE_PREFIX . 'customer'), 'finance_account.AccountId = ac.AccountId', array())
// using "array_unique()" to minimize db overhead
->where('AccountId IN (?)', array_unique($parentIds))
->setIntegrityCheck(false);
我没有任何其他列可以进行连接。我现在该怎么办?
AccountId 像 finance_account.AccountId 或 ac.AccountId 因为查询不明确 table 要查看
$select = $this->select() ->从(数组('finance_account' => DB_TABLE_PREFIX . 'finance_account'), 数组( 'AccountId', 'ParentAccountId', 'AccountGroupId', 'AccountPath', 'AccountCode', 'AccountName', 'Description' )) ->joinLeft(array('ac' => DB_TABLE_PREFIX . 'customer'), 'finance_account.AccountId = ac.AccountId', array()) // 使用 "array_unique()" 来最小化数据库开销 ->where('ac.AccountId IN (?)', array_unique($parentIds)) ->setIntegrityCheck(false);