伙计们,我的 mysql php 问题有问题 好的,我希望这可以从我的 mysql 数据库中提取表信息,其中以数字 10 显示名字,但我也想添加更多,例如 10 100 1000 其他数字怎么能我从这段代码中做到这一点
$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);
您必须将 = 更改为 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')");
查看示例