我想用兩個字符串參數構造一條SQL語句。基本上我正在用php查詢MS Access表。php MS Access多個字符串參數的SQL查詢
下面是我的語法正確嗎?
$parm1 = "TPMS";
$parm2 = "Clamp In";
$sql = "SELECT * FROM archive where productfamily like ".$parm1 ."and where productderivative like". $parm2;
現在我試了一個名爲$ parm1的參數字符串,字符串的語法如下。請注意,這是我用php查詢的MS Access表。
$parm1 = "'TPMS'";
現在相應的MS Access SQL語句是如下這些作品:
$sql = "SELECT * FROM archive where productfamily like $parm1 order by fullname asc"
現在用兩個參數相應的MS Access SQL語句不工作。有人可以告訴我爲什麼第二個參數在SQL語句中不起作用嗎?這可能是我的語法嗎?
$sql = "SELECT * FROM archive where productfamily like $parm1 and "
$sql .= "where productderivative like $parm2 order by fullname asc";
明天我會在這工作,謝謝 –