【发布时间】:2014-10-26 07:45:33
【问题描述】:
下面的一些变量(us1 或 sp1..)可能有空值(客户有可能不填写相应的文本视图)。我如何仅使用“not null”变量来语法“where”子句;例如,当 us1 不为空且 sp1 为空时,“where”子句必须为:“ where customer.username1 = 'us1'” 提前致谢
$us1 = $_POST['username1'];
$sp1 = $_POST['startPoli1'];
SELECT `username1`,`startPoli1`, `finalPoli1`,`weight1` ,`phone1`
FROM customer ,registration1
where customer.startPoli1 = 'sp1' and customer.username1 = 'us1'
【问题讨论】:
-
使用
if并动态构建查询。 -
在查询中使用 nvl?