夥計們即時通訊問題與我的MySQL的PHP問題好吧,我想這從我的MySQL數據庫中拉出表信息在它顯示數字10的名字,但我想添加更多像10 100 1000,其他號碼我怎麼能做到這一點,從這個代碼MYSQL + PHP的問題,其中名字
$result = mysqli_query($con,"SELECT * FROM tvshows
WHERE FirstName='10',100,1000");
夥計們即時通訊問題與我的MySQL的PHP問題好吧,我想這從我的MySQL數據庫中拉出表信息在它顯示數字10的名字,但我想添加更多像10 100 1000,其他號碼我怎麼能做到這一點,從這個代碼MYSQL + PHP的問題,其中名字
$result = mysqli_query($con,"SELECT * FROM tvshows
WHERE FirstName='10',100,1000");
SELECT * FROM tvshows WHERE FirstName IN (10,100,1000);
你可以看這裏:
http://dev.mysql.com/doc/refman/5.0/en/any-in-some-subqueries.html
這裏:
http://dev.mysql.com/tech-resources/articles/subqueries_part_1.html
如果你想選擇路線,你需要',例:
SELECT * FROM tvshows WHERE FirstName IN ('10','100','1000');
如果數字是這樣的:
SELECT * FROM tvshows WHERE FirstName IN (10,100,1000);
你必須改變= for IN
$result = mysqli_query($con,"SELECT * FROM tvshows WHERE FirstName IN(10,100,1000);
IN運算符允許您在WHERE子句中指定多個值。
$result = mysqli_query($con,"SELECT * FROM tvshows
WHERE FirstName IN('10','100','1000')");
爲參考平臺文檔見Example
+1。 – Kermit