select code, codename, codealias, comcode, othersignfrom ldcode
and code <> (case
when (select 1
from lccont b
where b.contno = 'w86190001290019'
and b.trdingchannel like 'zfb%') = 1 then
'-9'
else
'9'end)
and othersign = '1'
order by length(code), code asc
去掉(case when)
select code, codename, codealias, comcode, othersignfrom ldcode
and code <> '-9' and othersign = '1'
分析case when 1= 1 then '-9' else '9' end
(casewhen (select 1
from lccont b
where b.contno = 'w86190001290019'
and b.trdingchannel like 'zfb%') = 1 then
'-9'
else
'9'end)
分析 select 1
select 1 from lccont bwhere b.contno = 'w86190001290019'
and b.trdingchannel like 'zfb%'
select * ,select 某欄位,
可以用來查詢表中是否有符合條件的記錄(比如select 1 from seckill where id = 1001;
),select 1一般用來當作條件使用,比如exists( select 1 from 表名)等。select 1的效率比select 列名
和select*
快,因為不用查字典表。
乙個不會的SQL語句
12.有兩個表a 和b 均有key 和value 兩個字段,如果b 的key 在a 中也有,就把b 的value 換為a 中對應的value 這道題的sql 語句怎麼寫?update b set value select value from awhere a.key b.key where exi...
乙個神奇的SQL語句
題目是這樣的 分別往這兩張表中新增3條資料。查詢營業額最高商家的商品總價與營業額最低商家的商品總價差是多少 5分 create view vm2 as select price limit num as total money b.id from business b,goods g where b...
SQL語句學習記錄 一
一道例題 一.表查詢 t1.查詢 給定一張表 employees 員工號employee id 上司員工號 manager id 1 查詢並顯示所有存在下屬員工的員工號 建表 插入測試資料 insert into employees values 2,1 insert into employees ...