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

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    I am using MySQL and cant seem to get an ORDER BY and LEFT JOIN to work in the same SELECT statement.

    Is this an illegal statement?

    SELECT MsgParent, MsgID, MsgBody, MsgEvent, UserFirstName, UserLastName, UserCoName FROM msgbrd LEFT JOIN users ON msgbrd.MsgBy = users.UserName ORDER BY MsgEvent

    The Statement works as long as there is not an ORDER BY and JOIN in the same statement....

    HELP!

    Thanx
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    As I read the mySQL and mSQL book from O'Reilly, I understand that the use of
    "LEFT JOIN" is unnecessary..

    In this example I am performing a join of information for 2 tables, and then "order by" in "ascending order"...

    SELECT customer_id,account_num,name,company_name,host_acct,status,account_types.acct_type FROM customers, account_types
    WHERE account_types.acct_type_id=customers.acct_type_id
    ORDER BY customer_id ASC

    And I have experienced no problems,

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    Hmmm...

    I tried it and it still does not work...

    Here is my SQL Statement....

    SELECT msgbrd.MsgParent, msgbrd.MsgID, msgbrd.MsgBody, IF(msgbrd.MsgParent=0, msgbrd.MsgID, msgbrd.MsgParent) AS MsgOrder, DATE_FORMAT(msgbrd.MsgDate, '%m/%d/%y %r') AS MessageDate, msgbrd.MsgEvent, users.UserFirstName, users.UserLastName, users.UserCoName FROM msgbrd, users WHERE msgbrd.MsgBy = users.UserName ORDER BY MsgOrder ASC


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Robert_J_Sherman:
    As I read the mySQL and mSQL book from O'Reilly, I understand that the use of
    "LEFT JOIN" is unnecessary..

    In this example I am performing a join of information for 2 tables, and then "order by" in "ascending order"...

    SELECT customer_id,account_num,name,company_name,host_acct,status,account_types.acct_type FROM customers, account_types
    WHERE account_types.acct_type_id=customers.acct_type_id
    ORDER BY customer_id ASC

    And I have experienced no problems,

    [/quote]

Similar Threads

  1. order results after left join
    By buckenmeyer in forum MySQL Help
    Replies: 2
    Last Post: January 29th, 2004, 09:42 AM
  2. count + join + group by + order by
    By gig745 in forum MySQL Help
    Replies: 3
    Last Post: October 13th, 2003, 09:10 PM
  3. After join order by not workin
    By nivaspm in forum MySQL Help
    Replies: 7
    Last Post: June 22nd, 2003, 07:14 AM
  4. mutiple ORDER BY after JOIN
    By Geert bcn in forum MySQL Help
    Replies: 2
    Last Post: September 9th, 2002, 07:10 AM
  5. SELECT, LEFT JOIN, ORDER question
    By Chern Ann in forum MySQL Help
    Replies: 2
    Last Post: May 2nd, 2002, 04:33 AM

IMN logo majestic logo threadwatch logo seochat tools logo