2
$query = db_select('drupal5users', 'udf');
$query->leftJoin('drupal5users_roles', 'ur');
$query->fields('udf', array('uid','name','pass','mail','created','access','login','status','language','init'));
$query->fields('ur', array('rid'));

The above gives me the following error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') subquery' at line 1.

If I comment out $query->leftJoin and the second $query->fields line, it works, so the problem lies with leftJoin. What am I doing wrong here?

1 Answer 1

4
$query->leftJoin('drupal5users_roles', 'ur', 'udf.uid = ur.uid');
1
  • Thanks, worked like a charm! Now just to fix up whatever logic error I still have left in my code :).
    – Peter
    Commented Nov 7, 2011 at 5:52

Your Answer

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

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