ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 Can anyone suggest me, give me an example with the use of OR in mysql query?ThanksTed Link to comment https://forums.phpfreaks.com/topic/36158-solved-can-you-use-or-in-mysql-query-if-so-how-do-you-use-it/ Share on other sites More sharing options...
trq Posted January 29, 2007 Share Posted January 29, 2007 [code]SELECT foo FROM bar WHERE foo = 'bob' OR foo = 'boo';[/code]or[code]SELECT foo FROM bar WHERE foo = 'bob' || foo = 'boo';[/code] Link to comment https://forums.phpfreaks.com/topic/36158-solved-can-you-use-or-in-mysql-query-if-so-how-do-you-use-it/#findComment-171705 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Author Share Posted January 29, 2007 I tried this:$query_count = "SELECT * FROM friendlist WHERE username='$username' AND status='pending' OR status='declined'"and it doesnt work, is it because of the way i organised it?Ted Link to comment https://forums.phpfreaks.com/topic/36158-solved-can-you-use-or-in-mysql-query-if-so-how-do-you-use-it/#findComment-171707 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Author Share Posted January 29, 2007 sorry, my bad... i think it works...Ted Link to comment https://forums.phpfreaks.com/topic/36158-solved-can-you-use-or-in-mysql-query-if-so-how-do-you-use-it/#findComment-171708 Share on other sites More sharing options...
trq Posted January 29, 2007 Share Posted January 29, 2007 You should group it within braces.[code]$query_count = "SELECT * FROM friendlist WHERE username='$username' AND (status='pending' OR status='declined')";[/code] Link to comment https://forums.phpfreaks.com/topic/36158-solved-can-you-use-or-in-mysql-query-if-so-how-do-you-use-it/#findComment-171710 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Author Share Posted January 29, 2007 Thanks ;D Link to comment https://forums.phpfreaks.com/topic/36158-solved-can-you-use-or-in-mysql-query-if-so-how-do-you-use-it/#findComment-171713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.