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

    Join Date
    Oct 2000
    Posts
    1
    Rep Power
    0
    The following SELECT returns no record:

    SELECT * from
    ((t1 LEFT JOIN t2 on t1.f1=t2.f1)
    LEFT JOIN t3 on t1.f2=t3.f2)
    ORDER BY t1.f1

    However by getting rid of "ORDER BY" clause:
    SELECT * from
    ((t1 LEFT JOIN t2 on t1.f1=t2.f1)
    LEFT JOIN t3 on t1.f2=t3.f2)
    will return all the records.

    Why? Please advise.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    81
    Rep Power
    15
    Not positive on this one, but there may be some restrictions on using things like ORDER BY and GROUP BY on left joined queries, as there's a risk that there could be NULL values floating round in funny places (e.g. in your example, you may have a bunch of t1.f1 values with no corresponding t2.f1 values). This doesn't entirely make sense -- you may have a hit a bug -- but it might offer some reason as to why the bug is there. Get onto one of the MySQL mailing lists and pose your question there.

Similar Threads

  1. problems with "order by"
    By houyi99 in forum MySQL Help
    Replies: 3
    Last Post: September 23rd, 2003, 12:04 AM
  2. array sorting like "order by" in sql...?
    By buddinghere in forum PHP Development
    Replies: 1
    Last Post: September 12th, 2003, 01:59 PM
  3. Need help with "order by", "group by"
    By lnong in forum MySQL Help
    Replies: 0
    Last Post: August 7th, 2003, 07:41 AM
  4. Cronjob madness
    By eliteboo in forum Linux Help
    Replies: 10
    Last Post: July 14th, 2003, 11:49 AM
  5. Is this "ORDER BY" possible?
    By redCashion in forum MySQL Help
    Replies: 3
    Last Post: June 28th, 2003, 03:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo