www.webdeveloper.com
Results 1 to 3 of 3

Thread: LEFT JOIN Optimisation!

  1. #1
    Join Date
    Aug 2006
    Posts
    126

    LEFT JOIN Optimisation!

    Hi all,

    I have the following query:

    Code:
    SELECT orders.*, order_lines.*
    FROM orders
    WHERE DATE(orders.timestamp) BETWEEN '2009-04-01' AND '2009-06-30'
    LEFT JOIN order_lines
    ON orders.txn_id = order_lines.transaction_id
    ORDER BY orders.timestamp ASC
    I can't see anything wrong with the syntax however whenever I execute it I get a 500 Internal Server Error back from phpMyAdmin.

    Firstly, is the syntax of this query correct?

    Secondly, can it be optimized to perform correctly?

    Thanks!

    dai.hop

  2. #2
    Join Date
    Jun 2009
    Posts
    36
    I think the JOIN has to come before the WHERE.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,392
    Quote Originally Posted by triassic View Post
    I think the JOIN has to come before the WHERE.
    Yes, the WHERE should be the last thing before the ORDER BY in that query.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles