SQL 大佬来救命

查看 173|回复 14
zjsxwc   
SELECT
rownum as xh, *
FROM
q_materialfusion
where sjbj = '0'
and (
instr(mc, '1') > 0
OR instr(ssxmmc, '1') > 0
OR instr(ssxtzc, '1') > 0
OR instr(xinghao, '1') > 0
OR instr(gg, '1') > 0
)
and rownum = 1

order by nf desc, mc asc
JC1027   
```
SELECT
rownum as xh,
t.*
FROM (
SELECT *
FROM q_materialfusion
WHERE sjbj = '0'
AND (
mc LIKE '%1%'
OR ssxmmc LIKE '%1%'
OR ssxtzc LIKE '%1%'
OR xinghao LIKE '%1%'
OR gg LIKE '%1%'
)
ORDER BY nf DESC, mc ASC
)
WHERE rownum BETWEEN 1 AND 500;
```
samv2   
@samv2 #9 其实不确定算不算优化,手动狗头
bugsystem   
通意千问说改成这样
SELECT
t.rownum as xh,
t.*
FROM
(
SELECT
*
FROM
q_materialfusion
WHERE sjbj = '0'
AND ( instr(mc, '1') > 0
OR instr(ssxmmc, '1') > 0
OR instr(ssxtzc, '1') > 0
OR instr(xinghao, '1') > 0
OR instr(gg, '1') > 0)
ORDER BY
nf DESC,
mc ASC
) t
WHERE
t.rownum >= 501
zjsxwc   
@zjsxwc
![sql7f63f62d0af1e49f.png]( https://youjb.com/images/2023/05/22/sql7f63f62d0af1e49f.png)
您需要登录后才可以回帖 登录 | 立即注册

返回顶部