Home > Backend Development > PHP Tutorial > mysql_query()中的sql话语好像不能带括号

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

WBOY
Release: 2016-06-13 12:46:20
Original
926 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template