Need some help on an MySQL query -
i stuck on query.
my problem in syntax. can't seem find correct way match records in "like" clause , exclude records not match "like" clause.
i using case statement because need format output according conditions.
sample of mysql code using posted below.
i have included image showing how desire output formatted.
the image of desired output found below.
select distinct s.salesid, ss.contact case contact when contact '%manuel%' works when contact not '%manue%' no end manuel? salespeople s left join studios ss on (s.salesid = ss.salesid) ss.contact = 'manuel austin' or ss.contact not null;
you have lot of syntax problems in query.
you can use query:
select s.salesid, case when ss.contact '%manuel%' 'working manuel' else 'not working manuel' end manuel salespeople s left join studios ss on (s.salesid = ss.salesid) group s.salesid, case when ss.contact '%manuel%' 'working manuel' else 'not working manuel' end order s.salesid
you shouldn't check in clause manuel or when column null, since need results no matter if have manuel contact.
so need left join, , use case.
Comments
Post a Comment