| 
 Posted by Jerry Stuckle on 12/02/07 19:33 
Oliver Grätz wrote: 
> 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 
> 
 
Subqueries are almost never correct.  Joins are much better. 
 
> 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 
>  
 
 
--  
================== 
Remove the "x" from my email address 
Jerry Stuckle 
JDS Computer Training Corp. 
jstucklex@attglobal.net 
==================
 
[Back to original message] 
 |