MySQL offers some ways to perform things that you might put in your application logic. For example, say you want to find the oldest people in a database with an age column.
SELECT name, age FROM persons WHERE age = (SELECT MAX(age) FROM persons)
This would select only the rows that have the highest integer in the age column (so it would select one or more people).
But you could also just do:
"SELECT name, age FROM persons"
and then use the results of this query to do some php to find the oldest people.
In general, which is better for speed and performance? I generally try to minimize using my database usage for doing logic, but I don't know if this is a good plan or where to draw the line. It would be helpful to have a good rule of thumb to judge whether I should use the database to do a calculation or organization over php and vice versa.



Reply With Quote





)

Bookmarks