jakebur01 Posted October 9, 2009 Share Posted October 9, 2009 What would be the correct way to do this? $result = mysql_query("SELECT * FROM extreme where `State` = 'AK' and `Store` = 'B & R' and`Store` = 'Extreme' order by City", $db) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/177130-select-statement/ Share on other sites More sharing options...
Daniel0 Posted October 9, 2009 Share Posted October 9, 2009 In what sense? I can tell you the "or die(mysql_error())" is not correct in any way though Quote Link to comment https://forums.phpfreaks.com/topic/177130-select-statement/#findComment-933972 Share on other sites More sharing options...
jakebur01 Posted October 9, 2009 Author Share Posted October 9, 2009 it is not pulling anything.... I was unsure if `Store` = 'B & R' and`Store` = 'Extreme' was the correct way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/177130-select-statement/#findComment-933977 Share on other sites More sharing options...
corbin Posted October 9, 2009 Share Posted October 9, 2009 Well, Store can't equal two values at the same time unless the two values are equal, and they're not. So, sounds like maybe you're looking for an OR? SELECT * FROM extreme where `State` = 'AK' and (`Store` = 'B & R' OR `Store` = 'Extreme') order by City By the way, ` are used only in the MySQL SQL dialect, and they're only useful if the object is a reserved word, so they should typically be avoided. (They detract from SQL compatibility, and reserved words shouldn't ever be used anyway.) Quote Link to comment https://forums.phpfreaks.com/topic/177130-select-statement/#findComment-933983 Share on other sites More sharing options...
Daniel0 Posted October 9, 2009 Share Posted October 9, 2009 By the way, ` are used only in the MySQL SQL dialect, and they're only useful if the object is a reserved word, so they should typically be avoided. (They detract from SQL compatibility, and reserved words shouldn't ever be used anyway.) You can easily abstract yourself out of that problem. Quote Link to comment https://forums.phpfreaks.com/topic/177130-select-statement/#findComment-933984 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.