0

The below query results in the following error:

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);

I don't have any other column to do the join. What am I supposed to do now?

2
  • 3
    You need to specify the table for AccountId, like table.AccountId because your query doesn't know which table to look at. Commented May 11, 2015 at 17:36
  • Wow!That saves.Thank you so much Jay. Commented May 11, 2015 at 17:39

1 Answer 1

1

AccountId put like finance_account.AccountId or ac.AccountId because query ambiguous on which table to look at

$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('ac.AccountId IN (?)', array_unique($parentIds)) ->setIntegrityCheck(false);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.