MySQL select query return unrelated output -


select updatedate, id,cssn,clname,cfname,cdob,cdod,ccity,cstate,chospital,ccurstatus,cmmrcashworker,ctelephone med_patient ccurstatus!='completed' , cmmrcashworker = '2' , chospital = '1234' or chospital1 = '1234' or chospital2 ='1234' , updatedate between '1/30/2010' , '1/28/2010' order id desc' 

output:

updatedate   chospital   chospital1     chospital2  01/15/2010   1234  01/15/2010   1234 

but acutally knowledge query must return empty row.

where mistake in query?

try adding parentheses chospital condition, otherwise or not expect:

ccurstatus!='completed' , cmmrcashworker = '2' , (chospital = '1234' or chospital1 = '1234' or chospital2 ='1234') , updatedate between '1/30/2010' , '1/28/2010' order id desc' 

also:

... updatedate between '1/30/2010' , '1/28/2010' ... 

^ doing string compare rather date comparison, try changing to:

... updatedate between '2010-01-30' , '2010-01-28' ... 

Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -