Re: Sorting UK Postcodes (WAS Sorting Results)
Damien -- What about: select substring(code, 1, 1) as letter, substring(code, 2, 2) + 0 as number from epost order by 2 +++ | letter | number | +++ | E | 1 | | E | 2 | | E | 3 | | E | 4 | | E | 10 | | E | 11 | | E | 12 | | E | 13 | +++ 8 rows in set (0.00 sec) Then just use your scripting language to join the letter and number back together. I tried mysql concat() but it makes the whole thing into a wrong-sorted string again. FWIW -- Doug At 10:17 PM 12/12/2002 +0100, Alliax wrote: Hi, What about if you want to sort UK Postcodes ? They can be E1,E2,..,E12,E13 Order by name would do: E1,E10,E11,E12,E13,E2,E3,E4,... how can I get with a simple ORDER BY query E1,E2,E3,E4,E5,... ? Cheers, Damien COLA - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
re: mysql client question
If you're on a unix-like machine, you might be able to just type edit at the mysql prompt, which might take you to a vi session, much better for editing complex sql commands. When you want to execute the command, in vi just do ZZ, which will take you back out to mysql client. Type go or \G to execute the command you crafted in vi. Or, just use any another editor (e.g. Notepad, vim, etc.) to make your sql command, then copy and paste it all at the mysql prompt. HTH, Doug You wrote: Alright, this may come across as a stupid question - In the mysql client, is there any way to get rid of the damn - sign when you are writing a query out? I ask because it'd make it alot easier to copy and paste the query back in, if lets say, I messed up on a single item. mysql create table locations( address varchar(255) not null, - city varchar(100) not null, - state varchar(50), - country_id int not null) - PRIMARY KEY ( address, city, country_id ); ERROR 1064: You have an error in your SQL syntax near 'PRIMARY KEY ( address, city, country_id )' at line 5 If the damn '-' wasn't before each line, I could just copy and paste and correct the error. Anyone know how to get rid of it? \: -- sh - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php