This is a discussion on SQL Query within the Coding Help forums, part of the Webmaster Help category; I have this query below: Code: $sql = "SELECT id,name,date FROM releases WHERE date>='".date("Y-m-d")."' ORDER BY date ASC LIMIT ".$limit.""; ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||||
| I have this query below: Code: $sql = "SELECT id,name,date FROM releases WHERE date>='".date("Y-m-d")."' ORDER BY date ASC LIMIT ".$limit."";
Now what im trying to do which wont work for me is to take the five '24' dated ones and order from a-z and then the five '28' ones and order from a-z like below: 24-08-2007 a 24-08-2007 c 24-08-2007 h 24-08-2007 m 24-08-2007 q 28-08-2007 d 28-08-2007 i 28-08-2007 o 28-08-2007 r 28-08-2007 w Can anyone see where im going wrong? |
| |||||
| Well taking the a-z column as "LETTER" you would do this: $sql = "SELECT id,name,date FROM releases WHERE date>='".date("Y-m-d")."' ORDER BY date ASC, LETTER ASC LIMIT ".$limit.""; |
| |||||
| Sorry, i was really clear there, they aren't just letters, there strings but i want them from a-z based on the first character of the string, if you get me?!? |
| |||||
| Ok, don't know how I missed the name column in the query! Well surely the query would be this then: (simply order by date, then order by name alphabetically) $sql = "SELECT id,name,date FROM releases WHERE date>='".date("Y-m-d")."' ORDER BY date ASC, name ASC LIMIT ".$limit.""; |
| |||||
| Thanks david, i was using the query below with the 'AND' statement which was messing up the results, thanks again. Code: $sql = "SELECT id,name,date FROM releases WHERE date>='".date("Y-m-d")."' ORDER BY date ASC AND name ASC LIMIT ".$limit."";
|
| Tags |
| query, sql |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Contract and Resignation Query | Cormac | The Business Aspects of Web Work | 4 | 04-10-2007 10:12 AM |
| More powerful server... how much faster will my SQL queries be? | dude | Server / Technical Administration Tips and Queries | 14 | 13-08-2007 09:45 AM |
| MS SQL Web Interfaces? | blacknight | Server / Technical Administration Tips and Queries | 12 | 09-03-2007 10:48 AM |
| Importing XML files into MS SQL | davidbehan | Coding Help | 0 | 06-02-2007 06:00 PM |
| MS SQL Tutorials / Resources | blacknight | Server / Technical Administration Tips and Queries | 0 | 17-01-2007 10:09 AM |
| ||||||||
| | ![]() | |||||||