gpt4 book ai didi

mysql - 很长的SQL Query,能不能优化一下

转载 作者:搜寻专家 更新时间:2023-10-30 21:38:45 24 4
gpt4 key购买 nike

我有一个很长的标准格式的 SQL 查询

select * 
from salary
where employe_id = 101
OR employe_id = 102
OR employe_id = 103
OR employe_id = 104
OR employe_id = 105
........................ repeated 1000's of times.

我的问题是 sql 查询有最大长度。这可能是我设计中的瓶颈。

我的问题是,

is there a way to optimize this query to say something like where employe_id = 101, 102, 103.

或者更好

is there a way to optimize this query into say something like where employe_id = <a csv file>.

我需要做到 limitless .

最佳答案

有几种方法可以做到这一点:

select * from salary where employee_id IN(101, 102 ... 105); 
select * from salary where employee_id BETWEEN 101 AND 105;
select * from salary where employee_id >= 101 AND employee_id <= 105;

关于mysql - 很长的SQL Query,能不能优化一下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32564961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com