mysql select *... where id in (select 字符串 from ... )查询结果问题?
2013-12-10 17:32
831 查看
SQL中的写法为
查询结果为:
id TypeName
1 新手
2 手机
在MYSQL中
查询结果为:
id TypeName
1 新手
少了一条数据.
其中
查询结果为
问题就出在了子查询中.'1,2' 不会当作 1,2 来查询
可以使用
进行查询
查询结果为:
id TypeName
1 新手
2 手机
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 手机
相关文章推荐
- 解决 Select * from TableName where ID in (@ids) 问题
- Mysql模糊查询 select count(*) from sys_invitation where from_id like '%1006%';
- MSSQL和MYSQL中select where in的查询结果按where条件顺序排序的方法
- LINQ中in的实现方法-LINQ To Entities如何实现查询 select * from tableA where id in (1,2,3,4)
- LINQ To Entities如何实现查询 select * from tableA where id in (1,2,3,4) ?
- 让sql语句不排序,按照in语句的顺序返回结果mysql:SELECT*FROMEVENTWHER
- 醉了,mysql的删除居然变得这么麻烦 delete from table where id in()
- 共享锁select * from t1 where id=2 LOCK IN SHARE MODE;
- MySQL 存储过程传参数问题:实现 where id in(1,2,3,...)
- mysql中使用FIND_IN_SET查询在逗号隔开的字符串中符合多个ID的数据
- MySQL 存储过程传参数问题:实现 where id in(1,2,3,...)
- 详解 Mysql查询结果顺序按 in() 中ID 的顺序排列
- MySQL查询优化:LIMIT 1避免全表扫描【如判断用户是否存在select * from users where username='123' and passwd='123' limit 1】
- Mysql查询结果顺序按 in() 中ID 的顺序排列
- sql Split函数(WHERE RouterID IN (SELECT Item FROM dbo.Split(@routerIds,',')))
- Mysql查询结果顺序按 in() 中ID 的顺序排列
- Mysql 中 查询结果顺序按 IN 关键字中ID 的排列
- MySQL 存储过程传参数问题:实现 where id in(1,2,3,...)
- MySQL 存储过程传参数问题:实现 where id in(1,2,3,...)
- mysql中使用FIND_IN_SET查询在逗号隔开的字符串中符合多个ID的数据