用多个id,查询出一个表中多条数据,比如,id有 001 005 006,表中id从1-1000都有的话,那么 怎么用Mysql语句查询呢?
6条回答 默认 最新
- print_out 2021-11-19 10:10关注
1、如果是mysql数据库中直接使用语句
select 列名 from 表名 where id in('001','005','006');
2、如果是在mybatis中
list中存放 001 005 006 这些<select id="selectList" resultMap=“你的实体类的map”> <if test="list!=null and list.size()>0"> select 列名 from 表名 where id in <foreach collection="list" item="id" open="(" close=")" separator=","> #{id} </foreach> </if> </select>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录