Please help me with this SQL query

Discussion in 'MySQL' started by wowla_123, Apr 27, 2008.

  1. #1
    I am unable to execute the following query on MySQL:

    SELECT DISTINCT
                    v.variableid AS variable_id,
                    v.name AS variable_name,
                    v.description AS variable_description,
                    t.trackerid AS tracker_id,
                    t.trackername AS tracker_name,
                    t.description AS tracker_description
                FROM
                    ox_ad_zone_assoc aza JOIN
                    ox_zones z ON (aza.zone_id = z.zoneid) JOIN
                    ox_banners b ON (aza.ad_id = b.bannerid) JOIN
                    ox_campaigns_trackers ct USING (campaignid) JOIN
                    ox_trackers t USING (trackerid) JOIN
                    ox_variables v USING (trackerid) LEFT JOIN
                    ox_variable_publisher vp ON (vp.variable_id = v.variableid AND vp.publisher_id = z.affiliateid)
                WHERE
                    z.zoneid = '1' AND
                    v.datatype = 'numeric'
    Code (markup):
    I'm getting the following error:

    You have an error in your SQL syntax near 'ON (aza.zone_id = z.zoneid) JOIN ox_banners b ON (aza.ad_id = b.' at line 11

    Please note that this query is not written by me but a part of OpenX Ads system and I'm getting this error in their ads system, but I tried it using PHPMyAdmin too and getting the same error.

    Please tell me what is the reason of this error.

    Thanks
     
    wowla_123, Apr 27, 2008 IP
  2. sukosari

    sukosari Active Member

    Messages:
    63
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #2
    make sure all of fields you type is exist. in this case make sure you have zone_id at table ox_ad_zone_assoc and have zoneid at table ox_zones and more

    btw what version of your mysql?
     
    sukosari, Apr 27, 2008 IP
  3. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply. I have checked and these fields/columns exist in these tables. I have version 3.23.58 of MySQL.
     
    wowla_123, Apr 27, 2008 IP
  4. mspider

    mspider Guest

    Messages:
    231
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe you check if this version of mysql support this kind of notation!?
     
    mspider, Apr 28, 2008 IP
  5. sukosari

    sukosari Active Member

    Messages:
    63
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #5
    try to group every join
    such this:
    FROM
    (((((((ox_ad_zone_assoc aza JOIN
    ox_zones z ON (aza.zone_id = z.zoneid)) JOIN
    ox_banners b ON (aza.ad_id = b.bannerid)) JOIN
    ox_campaigns_trackers ct USING (campaignid)) JOIN
    ox_trackers t USING (trackerid))) JOIN
    ox_variables v USING (trackerid)) LEFT JOIN
    ox_variable_publisher vp ON (vp.variable_id = v.variableid AND vp.publisher_id = z.affiliateid))

    i am not sure mysql3.x support JOIN, that I am very sure MysQL5 is powerfull, support LEFT JOIN, RIGHT JOIN, trigger, storeprocedure
    why not to change to mysql5?
     
    sukosari, Apr 28, 2008 IP
  6. MattC1983

    MattC1983 Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    does MySQL support JOIN? I thought it had to be LEFT JOIN, RIGHT JOIN, INNER JOIN etc. Might be wrong tho :\
     
    MattC1983, Apr 29, 2008 IP
  7. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks everyone for the help. The code given by Sukosari didn't work either :( I think I need to upgrade MySQL and it will solve such this problen.
     
    wowla_123, May 1, 2008 IP