Welcome to WebmasterWorld Guest from 54.226.238.178

Forum Moderators: open

Message Too Old, No Replies

Quick Query Question.

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

Junior Member

10+ Year Member

joined:July 28, 2006
posts: 168
votes: 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

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

Administrator

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

joined:July 31, 2003
posts:12541
votes: 1


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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 0


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