|
Posted by Oliver Grδtz on 12/02/07 14:14
Ciaran schrieb:
> Cool solution there Chuck - best one so far by my reckoning! My select
> statement is too complicated for me to sort results by date as Oliver
> suggested - It's selecting various fields across multiple tables.
That doesn't matter. If your query is "too complicated", you can always
work with subqueries:
SELECT wanted_field_1,wanted_field_2
FROM (SELECT with your complicated query)
AS subtable
ORDER BY field_you_want_to have_the_max_value DESC
LIMIT 1
You are learning at the wrong end! If you say "my select statement is
too complicated" you are saying "I should learn to understand my query"
and not "It's bloated already, so let me find an even more bloated way
to search through my results".
Rule of thumb: If you have to sort/rearrange/manipulate your database
query result afterwards, then your query was wrong in the first place.
MySQL in version 5 has matured on the language level. You can even store
your complicated query as a VIEW and then select the maximum from that
view instead.
=> Invest one or two hours in reading some docs on http://dev.mysql.com
OLLi
--
No, that's me talking. I'm the doctor, you're the police woman, remember?
[Fitz on Cracker 206]
Navigation:
[Reply to this message]
|