Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple conditions with MySQL string in PHP

Status
Not open for further replies.

nerdhurd2

Technical User
Jul 5, 2005
7
US
Greetings,

given :

SELECT * FROM leads Where rowid = '$rowid' AND company = '$currentusercompany' OR company = '$currentusercompany2'

Is there OR only comparing the company field variables or is it also including rowid and if rowid doesnt compare it will select it because a company matches?

Example:

rowid=555
$currentusercompany=test1
$currentusercompany2=test2

which database records would be selected?:

rowid company
555 test1
554 test2
553 test1

ONLY the record with rowid 555 should be selected right? sense rowid 555 is a requirement but it can be eighter company...

Sorry for the wierd example, im just not sure how to word it better

 
According to MySQL's AND operator has precedence over MySQL's OR operator.

So in MySQL:

"a AND b OR c" will be interpreted as "(a AND b) OR c"

So, no, rowid 555 will not be the only record returned. Rowid 554 will also be returned.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top