用户名表管理地区表,显示二级双地区信息

select f.add_id,(select from my.law_area a1 where = a.parent_id) as , from my.law_firm f left join my.law_area a on f.area_id =

select * from my.law_firm f left join my.law_area a on f.area_id = left join my.law_area a1 on a.parent_id =

select 嵌套、关联查询优化

1. select .... from (subquery) as name ... ;

实例:
select a1,a2,a3
from (select b1 as a1,b2 as a2,b3 as a3 from bbb) as aaa

where a1 > 1;


2.用exists替代in嵌套查询:

实例:

select a1 from aaa

where a2 in(select b2 from bbb where b3 >10 ); 效率很低

select a1 from aaa

where exists(select b2 from bbb where bbb.b1=aaa.a1);效率最高


3.去掉字段中有'北京'的部分

update edb_bookweb_using.edb_hotelinfo

set hot_name_cn= trim(replace(hot_name_cn,'北京',''))

where hot_name_cn like '%北京%';