Jump to content

conditional select from table is giving unexpected result


funbinod

Recommended Posts

i'm trying to get some result from a table with some conditions

SELECT item FROM stock WHERE icode='$code' or bcode='$code' AND cid='$cid'

I intended to get result if any of two fields (icode or bcode) matched the entered value($code) for cid='$cid'. I was trying $cid=2 but it is giving result from $cid=1. but if I removed second OR condition (bcode='$code') then it gives the correct result.

 

its confusing. can u please guide if my code is good enough or not?????

Edited by funbinod
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...