homepage Welcome to WebmasterWorld Guest from 54.161.185.244
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Quick Query Question.
ryan_b83

5+ Year Member



 
Msg#: 3604107 posted 3:17 pm on Mar 18, 2008 (gmt 0)

Hi I have an ENUM value for "orderStatus", there are dozens of different statuses and instead of using a number for each status I used a string to help describe each status.

So with a simple example

orderStatus can be
Order Started
In Production
Paid
Shipped

What is the shortest way to select certian orderStatuses in a select statment.

Right now i have:
SELECT * FROM orders WHERE orderStatus = 'Order Started' OR orderStatus = 'In Production' OR orderStatus = 'Paid';

Is there a way to only refer to the "orderStatus" column once and give it a bunch of different possible values? The following syntax dosn't work but this would be the idea
SELECT * FROM orders WHERE orderStatus = ('Order Started','In Production','Paid');

I know it dosn't seem to be a huge time saver in this example, but if i have dozens of different statuses and several selects every script it adds up.

Thanks,
Ryan

 

coopster

WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3604107 posted 8:36 pm on Mar 18, 2008 (gmt 0)

IN() [dev.mysql.com] ?

Demaestro

WebmasterWorld Senior Member demaestro us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3604107 posted 8:49 pm on Mar 18, 2008 (gmt 0)

SELECT * FROM orders WHERE orderStatus in ('Order Started','In Production','Paid');

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved