Community Documentation

Ambiguous key fields in queries

Last updated January 10, 2011. Created by mikeryan on January 10, 2011.
Log in to edit this page.

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 'field' 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:

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

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x, Drupal 7.x
Audience
Programmers

Administration & Security Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.