jeff5656 Posted September 16, 2010 Share Posted September 16, 2010 I want to have AND and OR but the following query gave me a syntac error: $q = "select * from todo where and username = '$username' AND (mrn = '$mrn' OR lname = '$lname')"; $results = mysql_query ($q) or die (mysql_error()); I looked on W3 and it looked just lie above so not sure where th syntax error is. Quote Link to comment https://forums.phpfreaks.com/topic/213567-combining-and-or-in-sql/ Share on other sites More sharing options...
trq Posted September 16, 2010 Share Posted September 16, 2010 You have an extra 'and' after your first 'where'. Quote Link to comment https://forums.phpfreaks.com/topic/213567-combining-and-or-in-sql/#findComment-1111637 Share on other sites More sharing options...
objnoob Posted September 16, 2010 Share Posted September 16, 2010 You should not have an 'AND' operand directly after your WHERE clause. try $q = "select * from todo where username = '$username' AND (mrn = '$mrn' OR lname = '$lname')"; Quote Link to comment https://forums.phpfreaks.com/topic/213567-combining-and-or-in-sql/#findComment-1111639 Share on other sites More sharing options...
jeff5656 Posted September 16, 2010 Author Share Posted September 16, 2010 DUH! Thanks - didnt see that :-) Quote Link to comment https://forums.phpfreaks.com/topic/213567-combining-and-or-in-sql/#findComment-1111640 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.