alilland alilland - 6 months ago 31
MySQL Question

write MySQL searching for more than one value in a column

SELECT
ID,
Division,
EffectiveDate,
PM,
case Status
when 0 then 'Dead'
when 1 then 'Active'
when 2 then 'Job'
when 3 then 'Pending'
when 4 then 'Sales Lead'
when 5 then 'Budget'
when 6 then 'Change Order'
end as Status,
Name,
Address,
ProjectType
FROM intranet.t_bidinfo
WHERE Division = 'TI'
AND EffectiveDate >= '2015-06-01'
AND Status = 6
ORDER BY EffectiveDate ASC
;


i need to return all the values with a status of 6 OR 2

i tried writing
AND Status = 6 or 2
but that doesnt work =/
is this accomplished by joining tables or is there a simpler way?

thanks

Answer
SELECT 
    ID, 
    Division, 
    EffectiveDate, 
    PM, 
    case Status 
        when 0 then 'Dead'
        when 1 then 'Active'
        when 2 then 'Job'
        when 3 then 'Pending'
        when 4 then 'Sales Lead'
        when 5 then 'Budget'
        when 6 then 'Change Order'
    end as Status, 
    Name, 
    Address, 
    ProjectType
FROM intranet.t_bidinfo
WHERE Division = 'TI'
AND EffectiveDate >= '2015-06-01'
AND ( Status = 6 OR Status = 2 )
ORDER BY EffectiveDate ASC