码迷,mamicode.com
首页 > 数据库 > 详细

mysql取某个字段中的内容有等于数组中某个元素的数据

时间:2018-08-08 00:55:15      阅读:434      评论:0      收藏:0      [点我收藏+]

标签:内容   style   prepare   width   span   select   等于   sele   class   

$arr =array("a","b","1","2");

假设表名为acticle,字段为isread,表如下

id isread
1 1,3,4
2 a
3 3

我们取这个表中isread字段的内容等于数组某个元素的数据

$stmt = $con->prepare("select * from acticle where isread IN (" . implode(‘,‘, $arr) . ")");

上面的语句会输出:

id=1,id=2这两行的数据。

mysql取某个字段中的内容有等于数组中某个元素的数据

标签:内容   style   prepare   width   span   select   等于   sele   class   

原文地址:https://www.cnblogs.com/xiede/p/9440483.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!