以下命令是我的sql select命令;
sqlcommand = "SELECT * FROM INVENTORY WHERE LOWER(SAPNO) LIKE LOWER('" + sapNo + "%') AND LOWER(PARTDESC) LIKE LOWER('" + partDesc + "%') AND LOWER(PARTNO) LIKE LOWER('" + partNo + "%') AND MINQTY = '" + minQty + "' AND QOH = '" + QOH + "' AND LOWER(CATEGORY) LIKE LOWER('" + category + "%') AND LOWER(EQUIPMENT) LIKE LOWER('" + equipment + "%')";
像类别和设备的例子是确认无效。其余的都有价值。即使类别和设备为空,如何选择行?因为只要设备和类别为空,我就会使用此注释,数据将不会显示!
非常感谢您的评论!! TQ
答案 0 :(得分:1)
您可以添加一些OR条件,以便返回可以使特定值为null的行。
AND (LOWER(CATEGORY) LIKE LOWER('" + category + "%') OR CATEGORY IS NULL) AND (LOWER(EQUIPMENT) LIKE LOWER('" + equipment + "%') OR EQUIPMENT IS NULL)