#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    3
    Rep Power
    0
    What's wrong about this query?

    SELECT groups.id, groups.name, groups.discount, Sum(objects.price) AS total
    FROM groups LEFT JOIN (objects RIGHT JOIN objectgroup ON objects.id = objectgroup.objectid) ON groups.id = objectgroup.groupid
    GROUP BY groups.id, groups.name, groups.discount;

    This query was cooked up by MS Access. I need to convert this in order to use it with mysql...

    I hope someone out there can help me.

    [This message has been edited by guidovl (edited November 17, 2000).]

    [This message has been edited by guidovl (edited November 17, 2000).]

    [This message has been edited by guidovl (edited November 17, 2000).]
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    1
    Rep Power
    0
    Answer from a non-MySQL specialist.

    ACCESS SQL use a syntax different than usual in oother DBMS

    You can use :

    SELECT g.id, g.name, g.discount,
    sum(o.price) as total
    FROM groups as g, objects as o,
    objectgroup as og
    WHERE o.id = og.objectid
    AND g.id = og.groupid
    GROUP BY g.id,
    g.name, g.discount;

    Use aliases for the tables make easier to read (FROM groups as g)

    The jointure from MS-ACCESS must be changed
    from LEFT JOINTURE, ... RIGHT JOINTURE
    by where_clause :
    WHERE o.id = og.objectid
    AND g.id = og.groupid
    for the columns involved in the jointure
    and adding all the tables in the from_clause
    FROM groups as g, objects as o,
    objectgroup as og

    I hope this will help you !


Similar Threads

  1. Replies: 3
    Last Post: January 26th, 2004, 04:38 PM
  2. Overwriting mysql query with the query results
    By onerandomday in forum PHP Development
    Replies: 1
    Last Post: January 14th, 2004, 05:45 AM
  3. what's wrong with this query
    By ironchef in forum Database Management
    Replies: 1
    Last Post: January 7th, 2004, 08:53 AM
  4. sql join syntax , what is wrong with my query?
    By kyliecoast in forum MySQL Help
    Replies: 5
    Last Post: January 4th, 2004, 08:04 PM
  5. Syntax error in INSERT INTO query
    By Lee Miles in forum Visual Basic Programming
    Replies: 6
    Last Post: December 19th, 2003, 08:37 AM

IMN logo majestic logo threadwatch logo seochat tools logo