[support] D7 Sql USING syntax

Kamal Palei palei.kamal at gmail.com
Fri Sep 21 14:32:50 UTC 2012


Thanks Nicolas
Tried your suggestion. It worked. Thanks.

Nancy, I did not understand your comment "do not convert select query", can
you kindly elaborate on it.

Thanks
Kamal


On Fri, Sep 21, 2012 at 2:10 PM, Nicolas Poulain <nico.poulain at gmail.com>wrote:

> 2012/9/21 Kamal Palei <palei.kamal at gmail.com>:
>  > Hi All
> > I am trying to write a sql query in D7.
> >
> >
> > SELECT id, exp, name FROM {resubmt_users_skills} LEFT JOIN
> > {resubmt_skill_ids} USING (id) WHERE resubmt_users_skills.uid = $user.uid
> >
> > The above query I want to write in D7.
> >
> >         $query = db_select('resubmt_users_skills' , 'us');
> >         $query->leftJoin('resubmt_skill_ids' , 'si');
> >         $query->condition('USING(id)');
> >         $query->condition('us.uid = :uid' , array(':uid' => $user->uid));
> >         $result = $query->execute()->fetchAssoc();
> >
> >  Looks above syntaxt is not correct. Can somebody pls tell me whats the
> > fault here and solution for that.
>
> Try out this syntax :
> $query = db_select('resubmt_users_skills' , 'us');
> $query->leftJoin('resubmt_skill_ids' , 'si', 'si.id = us.id');
>  $query->condition('us.uid = :uid' , array(':uid' => $user->uid));
> $result = $query->execute()->fetchAssoc();
>
>
>
> --
> Nicolas poulain
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120921/b4569bb4/attachment.html 


More information about the support mailing list