Two small PHP/MySQL questions?

mission.rubix

New member
1: I have this query in my php: $query="SELECT * FROM team WHERE type='current' ORDER BY cyear DESC";
(cyear is an integer, it means current school year) so if I enter year 10 for someone, year 11 for someone else and year 12 for someone else they are in the correct descending order, however, if I add someone as year 9, they go to the top?

2: How would I sub-query that so that they were put into year groups and then sub-ordered into alphebetical order?

Thanks for any help!
Thanks for all your help guys! I realised the first problem was when I re-made the table I forgot to make it an integer *hides* and the second one works fine (answer 1) thanks guys!!!
 
1 - should work fine, but check the type of the column, it might be different and you might need to cast
2 - you don't have subqueries for mysql, you will need to use JOIN statements for that.

Just a tip, don't use *, use the columns names even you if have to type them all. Every time that you use start, mysql needs to translate that into the columns names which will make you loose some of your performance.
 
Back
Top