[support] can any select query

Larry Garfield larry at garfieldtech.com
Thu Jul 24 05:09:26 UTC 2008


Don't use USING in queries.  I don't believe it is part of the official SQL 
standard (although I'm not certain of that).  Drupal convention either way is 
to use a fully qualified INNER JOIN, on which you can specify the table and 
field explicitly so there is no ambiguity.

On Wednesday 23 July 2008 9:32:01 pm bharani kumar wrote:
> SELECT r.nid, r.vid, r.uid, r.title, r.body, r.teaser, t.tid, t.name,
> v.vid, v.name, v.description
> FROM node_revisions AS r
> INNER JOIN term_node
> USING ( nid )
> INNER JOIN term_data AS t
> USING ( tid )
> INNER JOIN vocabulary AS v
> USING ( vid )
> LIMIT 0 , 30
>
> *MySQL said: *[image:
> Documentation]<http://dev.mysql.com/doc/refman/5.0/en/error-returns.html>
>  #1052 - Column 'vid' in from clause is ambiguous
>
> On Wed, Jul 23, 2008 at 11:28 PM, Chris Johnson <cxjohnson at gmail.com> wrote:
> > Note that in the vocabulary table and the term_data table, "vid"
> > stands for "vocabulary id".  In the node_revision table, "vid" stands
> > for "version id" (unfortunately).
> >
> > The following SQL should display all of the data from the tables
> > described (untested):
> >
> > SELECT r.nid, r.vid, r.uid, r.title, r.body, r.teaser, t.tid, t.name,
> > v.vid, v.name, v.description  FROM node_revision AS r INNER JOIN
> > term_node USING(nid) INNER JOIN term_data AS t USING(tid) INNER JOIN
> > vocabulary AS v USING(vid);

-- 
Larry Garfield
larry at garfieldtech.com


More information about the support mailing list