I am using migrate module to transfer data from one site to another here is my query

$query = Database::getConnection('db1', 'db1')
        ->select('users', 'u');
$query->leftjoin('field_data_field_user_insti_name', 'insti_name', 'insti_name.entity_id = u.uid and insti_name.bundle = \'user\'');
$query->leftjoin('users_roles', 'ur', 'ur.uid = u.uid');
$query->fields('u', array('uid', 'name', 'mail', 'pass', 'status'));
$query->fields('insti_name', array('field_user_insti_name_target_id'));
$query->condition('u.uid', '1', '>');
$query->condition('ur.rid', '6', '!=');

than I am getting this error

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

I found a solution for this problem that i have to add line

$this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));

After this error is solved, but don't know what this line do, is it safe to use this line


You have to add alias in MigrateSQLMap

$this->map = new MigrateSQLMap($this->machineName,  
       'uid' => array(  
           'type' => 'int',  
           'not null' => TRUE,  
           'alias' => 'u',  
) ;

Not the answer you're looking for? Browse other questions tagged or ask your own question.