You are here: Re: sorting a 3d array? « PHP Programming Language « IT news, forums, messages
Re: sorting a 3d array?

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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация