views:

39

answers:

1

Here is my query:

   select s.*,
          u.display_name 
     from wp_wdify_sites s, 
          wp_users u
LEFT JOIN wp_wdify_sitesmeta m ON (s.sid = m.site_id)
    where milestones like '%dateSubmitted%' 
      and milestones not like '%dateArchived%' 
      and u.ID = s.cid and did IN (0)
      and m.meta_key = 'aboutSite'`

The error I'm getting is #1054 - Unknown column 's.sid' in 'on clause'. The problem is, wp_wdify_sites.sid definitely does exist. It doesn't make sense.

+3  A: 

try something like this :

    select s.*,
           u.display_name 
      from wp_users u 
INNER JOIN wp_wdify_sites s ON u.ID = s.cid 
 LEFT JOIN wp_wdify_sitesmeta m ON (s.sid = m.site_id) 
     where milestones like '%dateSubmitted%' 
       and milestones not like '%dateArchived%' 
       and did IN (0) 
       and m.meta_key = 'aboutSite'

your LEFT JOIN ON clause is in the wrong place for joining wp_wdify_sites and wp_wdify_sitesmeta.

oedo
+1: Don't mix ANSI-89 and ANSI-92 JOIN syntax.
OMG Ponies
thanks for formatting it better, omg ponies :)
oedo
Thanks oedo. Works great.
Dennis Pedrie
cool, glad i could help. also take note of what omg ponies said, it's better to stick with one join syntax in a query (your original query had one using `t1 LEFT JOIN t2 ON t1.x = t2.x` and one using `t1, t2 WHERE t1.x = t2.x`. it SHOULD work anyway but it's better to use one syntax for ease of reading/modifying.
oedo