yangakw yangakw

sql 编程

in 代码read (36) 文章转载请注明来源!

今天研究了一个sql以后回来优化你

 

update tu_school_major_hot
set 
tu_school_major_hot.school_id = 
(
select tu_school.id as school_id 
from tu_school,tu_school_major  
where 
tu_school_major_hot.school_name = tu_school.en_school_name 
and 
tu_school_major_hot.major_name = tu_school_major.major_name 
and 
tu_school.en_school_name = tu_school_major.school_name 
limit 1
)  
,
tu_school_major_hot.category =  
(
select  tu_school_major.category 
from tu_school,tu_school_major  
where 
tu_school_major_hot.school_name = tu_school.en_school_name 
and 
tu_school_major_hot.major_name = tu_school_major.major_name 
and 
tu_school.en_school_name = tu_school_major.school_name 
limit 1
)   
,
tu_school_major_hot.major_id = 
(
select tu_school_major.id as major_id
from tu_school,tu_school_major  
where 
tu_school_major_hot.school_name = tu_school.en_school_name 
and 
tu_school_major_hot.major_name = tu_school_major.major_name 
and 
tu_school.en_school_name = tu_school_major.school_name 
limit 1
)  
WHERE
EXISTS 
(
select tu_school.id  
from tu_school,tu_school_major  
where 
tu_school_major_hot.school_name = tu_school.en_school_name 
and 
tu_school_major_hot.major_name = tu_school_major.major_name 
and 
tu_school.en_school_name = tu_school_major.school_name 
limit 1
)
;
jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

发表新评论
博客已运行
© 2017 yangakw
PREVIOUS NEXT
雷姆
拉姆