Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 3rd, 2006, 2:41 PM   #1
Xeoncross
Newbie
 
Xeoncross's Avatar
 
Join Date: Aug 2006
Posts: 11
Rep Power: 0 Xeoncross is on a distinguished road
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
Xeoncross is offline   Reply With Quote
Old Oct 3rd, 2006, 3:40 PM   #2
Gilward Kukel
Newbie
 
Join Date: Jun 2005
Location: Vienna, Austria
Posts: 15
Rep Power: 0 Gilward Kukel is on a distinguished road
SELECT * FROM names WHERE last REGEXP BINARY '^[A-D]'  ORDER BY last ASC
Gilward Kukel is offline   Reply With Quote
Old Oct 3rd, 2006, 3:47 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Oct 3rd, 2006, 4:48 PM   #4
sykkn
Hobbyist Programmer
 
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5 sykkn is on a distinguished road
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! */
sykkn is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC