php - How to use OR & AND in WHERE clause in mysql -


i'm new mysql & have table @ presently i'm fetching data

select * tablename name='$user' , date='$selecteddate' 

now want add 1 more column named status_id want select values i.e 1 or 2

i tried query

 select * tablename (name='ankit') , (date='2015-04-23') , (status_id='1' or status_id='2') 

but didn't work out.

please help.

well, need elements concerned or clause between parenthesis.

they not "needed", way (you use precedence order of , / or), best way readability.

and if status_id data type int, don't need ' ' around 1, , 2.

select *   tablename  name='ankit'  , date='2015-04-23'  , (status_id=1 or status_id=2)  

by way, in case, may use in clause

and status_id in (1, 2) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -