adamcannon Posted May 3, 2007 Share Posted May 3, 2007 Hello, Does anybody know why this WHERE statement doesn't work correctly? SELECT * from main WHERE (field=1 || field=2) && column=3 It seems this type of conditional works fine in PHP/Perl but not in MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/49767-solved-where-conditional-syntax/ Share on other sites More sharing options...
bubblegum.anarchy Posted May 3, 2007 Share Posted May 3, 2007 The above form of conditional syntax should work fine in MySQL though most use `OR` and `AND` - what results are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/49767-solved-where-conditional-syntax/#findComment-244107 Share on other sites More sharing options...
bubblegum.anarchy Posted May 3, 2007 Share Posted May 3, 2007 Just in case those field names are not just examples, try this instead: SELECT * FROM main WHERE (`field`=1 || `field`=2) && `column`=3 Quote Link to comment https://forums.phpfreaks.com/topic/49767-solved-where-conditional-syntax/#findComment-244108 Share on other sites More sharing options...
adamcannon Posted May 3, 2007 Author Share Posted May 3, 2007 The above form of conditional syntax should work fine in MySQL though most use `OR` and `AND` - what results are you getting? I'm getting: Empty set (0.00 sec) The statement works if I remove the AND part of the conditional. Must be something small I'm missing. Quote Link to comment https://forums.phpfreaks.com/topic/49767-solved-where-conditional-syntax/#findComment-244113 Share on other sites More sharing options...
adamcannon Posted May 3, 2007 Author Share Posted May 3, 2007 I just sort of figured out the problem. The actual statement includes a NULL in one of the conditionals and I think mysql has syntax for tackling this. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/49767-solved-where-conditional-syntax/#findComment-244116 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.