MySQL Forums
Forum List  »  InnoDB

Re: Subquries and Alias Help
Posted by: Josh Stuart
Date: April 18, 2008 06:25PM

I have changed it to the following which seems to be working well. Still couldn't purely use joins for it to work.


SELECT o.id AS 'ID', o.the_date, c.fname AS 'First Name', c.lname AS 'Last Name', o.payment_type AS 'Payment Type', s.name AS 'Status'
FROM orders o, customer c, `status` s, orderstatus os
WHERE c.id = o.fk_customer
AND os.fk_orders = o.id
AND s.id = os.fk_status
AND s.id = (
SELECT MAX( os2.fk_status ) AS 'maxstatus'
FROM orderstatus os2
WHERE os2.fk_orders = o.id
GROUP BY os2.fk_orders )

is this the most efficient way of doing things?

Showing rows 0 - 29 (1,771 total, Query took 0.0717 sec)

which seems pretty good.

Options: ReplyQuote


Subject
Views
Written By
Posted
3302
April 17, 2008 11:55PM
1915
April 18, 2008 09:29AM
Re: Subquries and Alias Help
1845
April 18, 2008 06:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.