如何写sql语句判断某个字段的值是否在某范围内 例如表table中有 id name 两个字段想通过sql语句获得id值为 1 或 7 或 8 或 13 的name值谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select name from table where id in (1,7,8,13) select name from tt where id in(1,7,8,13) (1,7,8,13)可以用数组表示么比如php的数组 在MYSQL中只能生成SQL语句,再动态执行set @asql=concat('select name from tt where id in(',参数数组,')');prepare stml from @asql;execute stml; 你可以在PHP代码中生成这个SQL语句啊。 这是啥意思如何放到mysql_query()语句中 用 implode函数 将你的数组转成字符串 再拼接sql语句 再用上面的in语句 你在php中遍历数组,组成SQL字符串,然后传给mysql_query() $ids = array(1,7,8,13);$sql = "select name from table where id in(".implode(",",$ids).")"; 刚学面向对象,怎么在方法中调用其他方法? PHP里如何使点按钮和按回车一样的效果 求助:用MyEclipse 开发php的具体配置环境步骤! 用循环读出数据库数据,为什么没数据的字段,单元格会没有边边? 用预处理就插入不了数据 date_default_timezone_get() 函数 我的网站进不了后台?? 自定义函数不能调用外部变量吗? 请教高手,我的php在输出汉字时是乱码,请问这是怎么回事吗?该怎么处理呢?谢谢! foxserv的下载地址...献给为配置php而着急的朋友! PHPer 应该侧重C ,C++ ,还是C#的学习? php解密,在线等,急啊
(1,7,8,13)可以用数组表示么比如php的数组
set @asql=concat('select name from tt where id in(',参数数组,')');
prepare stml from @asql;
execute stml;
这是啥意思如何放到mysql_query()语句中
$ids = array(1,7,8,13);
$sql = "select name from table where id in(".implode(",",$ids).")";