![]() |
|
| Domain Name Sales | Domain Software | Calculate UK Domain Drop Dates | Domain Registration | NameDrive | Domain Parking | Subscribe to our Domains For Sale newsletter |
| | ||||||
| Home | Register | Rules | Membership Upgrade | Domains For Sale | Domain Name Escrow | Mark Forums Read | Domain Classified | Chat Room |
| Website Design Discuss web design |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Administrator | MySql Select statement help please
I am working on DomainPrices.co.uk and want to sort the domain list by month, trouble is, when I do so, the SQL reads it as text and sorts it alphabetically and not by month as required. So I guess i need to change how I enter the month data for this to work, what's the best way? This is the SQL query code I am using: Code: $sql = mysql_query("SELECT * FROM `item` ORDER BY `Month` ASC"); |
| |
| | #2 (permalink) |
![]() |
If Month is a string, then the sort is working correctly, why not store Month as an integer or have a generic datetime rather than a seperate month field?
__________________ Alex Monaghan - Drop Catch & Drop Lists - PM for details Online Accounting|Pine Furniture|Barbie |
| |
| | #3 (permalink) |
![]() |
You could do it two ways: a) Change all the months to numbers (but you can do it relatively quickly by saying " update 'item' set 'month' = '01' where 'month' = 'January' " etc). b) Setup another table with two fields - monthnumber and monthtext - so it's "01", "January" blah blah "12", "December" and then do a cleverer query statement that links the month text to the number in your second table.
__________________ Droppr - finely tuned .uk dropcatching for Nominet members Gazebo | Flyers, Postcards | Tree Surveys | Dent Repairs Leeds | Poster Printing |
| |
| | #6 (permalink) |
![]() |
And remember to backup your data first - don't trust forum users not to break your data
__________________ Droppr - finely tuned .uk dropcatching for Nominet members Gazebo | Flyers, Postcards | Tree Surveys | Dent Repairs Leeds | Poster Printing |
| |
| | #7 (permalink) |
![]() |
Without seeing your code or schema it's diffucult to give specific advise, however I'd personally add a datetime field (saledate) to hold your date then do something like select name, monthname(saledate), other_fields_you_want from item order by month(saledate)
__________________ Alex Monaghan - Drop Catch & Drop Lists - PM for details Online Accounting|Pine Furniture|Barbie |
| |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Domain Name Community | Replies | Last Post |
| Domain name. How to select the right domain names - 24-7PressRelease.com (press release) | RSS | Domain Name News | 0 | 04-06-2007 10:59:12 AM |
| Domain name. How to select the right domain names - 24-7PressRelease.com (press release) | RSS | Domain Name News | 0 | 31-05-2007 07:59:07 AM |
| How to select a domain name for your company - Honolulu Star-Bulletin | RSS | Domain Name News | 0 | 26-03-2007 12:59:16 PM |
| bounce.co.uk - Public Statement from Nominet | Beasty | Domain Name Disputes | 11 | 28-09-2006 02:28:30 PM |
| moving mysql from one server to another | SecNam | General Board | 1 | 07-08-2005 12:29:32 PM |