高校查询语句 请问我想在一个有几十万记录的表中 选出上百条指定的记录不用in语句 怎么写 可以简洁高效? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 请用数据举例,in 、exists in ('asdf','qwer','cvb'……) 这种 用in 效率太慢了 有什么办法解决 1、这类数据是否有规则,比如是从table中where type = 'XXX'得到的。'asdf','qwer','cvb'……2、用in 效率太慢了您说的是指什么?人工输入'asdf','qwer','cvb'……太耗时还是表查询返回结果很耗时呢 这个是php执行后得出的字符串不是查询结果 不了解'asdf','qwer','cvb'不是通过查询返回结果得到的?效率慢是指什么? 创建个临时表,然后做JOIN比如创建临时表 create table tmp(col varchar(10) primary key)然后再 select * from table1, tmp using (col) 或者直接用select * from table1 where col='asdf'union allselect * from table1 where col='qwer'... 1。 直接使用 IN (38068,238833,308799 ... )2。 将 (38068,238833,308799 ... ) 放入临时表,然后用 JOIN3。 直接在程序中 执行多个 select * where id = 38068; select * from where id=238833; ...4。 使用 inner join (select 38068 union all select 238833 union all ... )http://topic.csdn.net/u/20090626/16/65f043cf-b9d9-4707-b660-9857461177f4.html?70266看看这个帖子吧 新年的最后一天,问个问题。 这两个表怎么计算库存 my sql的安装问题 这个语句改怎么写 MYSQL中的查询语句 实现论坛帖子数统计的问题 MySQL里时间查询问题? 请教一台机器装两个MySQL的问题--已经没有分了 怎么用SQL语句将一个表里的数据移动到另一个数据表? Mysql 的 chage db是指什么操作? load 命令更新部分列数据 SQL update 怎么写,类似于程序里的循环条件 简单的判断插入存储过程 MySQL连接数据库出错
用in 效率太慢了 有什么办法解决
'asdf','qwer','cvb'……2、用in 效率太慢了您说的是指什么?
人工输入'asdf','qwer','cvb'……太耗时还是表查询返回结果很耗时呢
不是查询结果
union all
select * from table1 where col='qwer'
...
2。 将 (38068,238833,308799 ... ) 放入临时表,然后用 JOIN
3。 直接在程序中 执行多个 select * where id = 38068; select * from where id=238833; ...
4。 使用 inner join (select 38068 union all select 238833 union all ... )http://topic.csdn.net/u/20090626/16/65f043cf-b9d9-4707-b660-9857461177f4.html?70266看看这个帖子吧