Ambiguous key fields in queries

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

If a column name in the source key passed to the map key appears in more than one table of the source query, you will get an error along the lines of:

Integrity constraint violation: 1052 Column 'id' in on clause is ambiguous

The alias for the table containing the column instance you want to use needs to be passed to the map class constructor:

    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'bid' => array(
          'type' => 'int',
          'not null' => TRUE,
          'alias' => 'b',
        ),
      ),
      MigrateDestinationNode::getKeySchema()
    )

Help improve this page

Page status: Not set

You can: