跳转到主内容
新派编程网 - 新潮编程理念,全新技术课堂!

mysql_query()中的sql话语好像不能带括号

mysql_query()中的sql语句好像不能带括号。

$rs= mysql_query("select * from cxjb2 where nam ".$_POST[select3]." $_POST[nam] and cat ".$_POST[select0]." $_POST[cat] and sha ".$_POST[select1]." $_POST[sha] and pri is NULL  or nam ".$_POST[select3]." $_POST[nam] and cat ".$_POST[select0]." $_POST[cat] and sha ".$_POST[select1]." $_POST[sha]");以上语句可以执行。

$rs= mysql_query("(select * from cxjb2 where nam ".$_POST[select3]." $_POST[nam] and cat ".$_POST[select0]." $_POST[cat] and sha ".$_POST[select1]." $_POST[sha]) and (pri is NULL  or pri is NOT NULL)");同样的逻辑关系转换成此语句时便不能成功执行了。

请问各位大大指教SQL

分享到:

------解决方案--------------------所有的sql指令都必须以 SQL 命令字开头

相关文章