![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2006
Posts: 11
Rep Power: 0
![]() |
Better way to Select from MySQL?
The MySQL query I came up that gives me the results I needs seems very bulky and I was wondering if anyone else, perhaps, saw a better way to do this:
SELECT * FROM names WHERE last LIKE 'A%' OR last LIKE 'B%' OR last LIKE 'C%' OR last LIKE 'D%' ORDER BY last ASC |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jun 2005
Location: Vienna, Austria
Posts: 15
Rep Power: 0
![]() |
SELECT * FROM names WHERE last REGEXP BINARY '^[A-D]' ORDER BY last ASC |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Less bulky, but regex is generally less efficient for simple searches.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
this should work ... no regex ...
SELECT * FROM names WHERE SUBSTRING(last,1,1) in ('A','B','C','D') ORDER BY last ASC
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Slackware installation guide for Linux beginners | coldDeath | Coder's Corner Lounge | 104 | Jul 29th, 2007 5:40 AM |
| Allow user to select a directory | MegaArcon | HTML / XHTML / CSS | 11 | Jun 5th, 2006 9:38 AM |
| reloading html select boxs...is there a better way? | MegaArcon | Python | 13 | May 26th, 2006 4:06 AM |
| Tutorial - Using MySQL in C# | Darkhack | C# | 12 | Jan 17th, 2006 10:28 AM |
| Simple Perl / MySQL Problem.. pls help! | domquemo | Perl | 0 | Jan 11th, 2006 5:08 AM |