我的PHP代码中有以下SQL语句:
$strSQL = "SELECT * FROM coaches WHERE pastors='1' OR all_categories='1' ORDER BY l_name";
but the WHERE portion after the OR is ignored. Is my code correct? Is there a better way to code it?
但忽略OR之后的WHERE部分。我的代码是否正确?有更好的方法来编码吗?
0
Thanks for the suggestions. Even though people said it should work, for some reason it wasn't. The easiest solution was to simply set every true/false to 1 for those individuals who want to be in all categories instead of trying to fight against the OR which looks correct but won't work.
谢谢你的建议。即使人们说它应该工作,但由于某种原因它不是。最简单的解决方案是简单地将每个真/假设置为1,以便那些希望处于所有类别而不是试图与OR看起来正确但不起作用的人。
-1
I am trying to get it to select database entries if there is a 1 in a particular category, in this case "pastors", or if there is a 1 in the "all_categories" category.
我试图让它选择数据库条目,如果特定类别中有1,在这种情况下是“牧师”,或者如果“all_categories”类别中有1。
From the looks of it, your code does just that.
从它的外观来看,你的代码就是这样。
You're just forgetting ASC or DESC at the end of it.
你最后忘记了ASC或DESC。
It should look more like this:
看起来应该更像这样:
$strSQL = "SELECT * FROM coaches WHERE pastors='1' OR all_categories='1' ORDER BY l_name ASC";
0
Thanks for the suggestions. Even though people said it should work, for some reason it wasn't. The easiest solution was to simply set every true/false to 1 for those individuals who want to be in all categories instead of trying to fight against the OR which looks correct but won't work.
谢谢你的建议。即使人们说它应该工作,但由于某种原因它不是。最简单的解决方案是简单地将每个真/假设置为1,以便那些希望处于所有类别而不是试图与OR看起来正确但不起作用的人。
-1
I am trying to get it to select database entries if there is a 1 in a particular category, in this case "pastors", or if there is a 1 in the "all_categories" category.
我试图让它选择数据库条目,如果特定类别中有1,在这种情况下是“牧师”,或者如果“all_categories”类别中有1。
From the looks of it, your code does just that.
从它的外观来看,你的代码就是这样。
You're just forgetting ASC or DESC at the end of it.
你最后忘记了ASC或DESC。
It should look more like this:
看起来应该更像这样:
$strSQL = "SELECT * FROM coaches WHERE pastors='1' OR all_categories='1' ORDER BY l_name ASC";