Welcome to WebmasterWorld Guest from 54.162.167.40

Forum Moderators: open

Message Too Old, No Replies

Quick Query Question.

     
3:17 pm on Mar 18, 2008 (gmt 0)

5+ Year Member



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

8:36 pm on Mar 18, 2008 (gmt 0)

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



IN() [dev.mysql.com] ?
8:49 pm on Mar 18, 2008 (gmt 0)

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



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

Featured Threads

Hot Threads This Week

Hot Threads This Month