If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
select table1.*,
CASE WHEN field1 > '10000' THEN '1'
WHEN field2 BETWEEN '5001' AND '9999' THEN '2'
WHEN field3 BETWEEN '2501' AND '5000' THEN '3'
WHEN field4 BETWEEN '0' AND '2500' THEN '4'
AS Class
FROM table1
I'd use MySQL's CASE, which should work just like MS-SQL's CASE. I'm highly suspicious that you didn't mean to use different column names (Field1 through Field4 in your example). That would be a bad thing in most cases!