您的位置:首页 > 数据库 > MySQL

mysql select *... where id in (select 字符串 from ... )查询结果问题?

2013-12-10 17:32 831 查看
SQL中的写法为

select id,TypeName from newcardtype where id in(select NewcardType from gamelist where id=43);


查询结果为:

id  TypeName

1  新手

2  手机

在MYSQL中

select id,TypeName from newcardtype where id in(select NewcardType from gamelist where id=43);


查询结果为:

id  TypeName

1  新手

少了一条数据.

其中

select NewcardType from gamelist where id=43


查询结果为

NewcardType
1,2

问题就出在了子查询中.'1,2' 不会当作 1,2 来查询

可以使用

select id,TypeName from newcardtype where  instr((select NewcardType from gamelist where id=43),id);


进行查询

查询结果为:

id  TypeName

1  新手

2  手机
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐