例如: select 100 in (select id from table1)结果如果存在是1, 不存在是0我现在想做一个query, 把一个id集合(100,101,102...)传入, 像这样select 100,101,102,103,104 in (select id from table1)明显这个语句的结果是100,101,102,103是列, 104 in (select id from table1)的结果是另一列了,不是我想要的.我要的是返回匹配的ID集合, 例如100,101是匹配的,查询结果看起来像:100
101
谢谢.
101
谢谢.
解决方案 »
- mysql 的order by 失效?
- 求一sql语句,有点复杂,在线等
- mysql安装时出错,十分迷茫,请高人解救!
- 我想在64位的ubuntu系统上安装一个带federated引擎的5.1.46版本的Mysql,该下载哪个版本?怎么安装?
- 如何遍历表中的某个字段?
- MYSQL 5.0,事务回滚的问题
- 如何限定MySQL数据库的大小?
- 为什么对一个字(中文)查询,返回结果不正确?
- 请问:为什么我的odbc数据源中看不到mysql这个数据源,而且我已经安装了mysql
- 请问,哪有mysql的入门教程下载的??
- 一条SQL语句经过函数计算后类型转成了blob类型,怎么回事
- 最近mysql slave上频发'Relay log read failure'错误
再问下另一个问题:表test里有一个unique field - ID, 现在insert ignore test(id) values (1), (2), (3)..;
这样可以安全的插入不存在的id吗? 换句话说遇到重复id就不插入...
INSERT IGNORE in the treatment of new rows that contain unique key values that duplicate old rows: The new rows are used to replace the old rows rather than being discarded.新的记录替换旧的记录
union all
select id from table1 where id =101
union all
...
union all
select id from table1 where id =104