1、
WITH這個(gè)東西主要是產(chǎn)生一個(gè)臨時(shí)的表,可以通過各種條件見小數(shù)據(jù)量,挑選需要的列,如此這般,數(shù)據(jù)量就會小很多。WITH沒有辦法提高效率,但是就是降低數(shù)據(jù)量,靠硬件的優(yōu)勢。修改以后的代碼如下:
with AA as (select id, name, code, type from A where id > 1000),
BB as (select type, pid from B),
CC as (select p_name, pid from C)
select AA.id, AA.name, AA.code, BB.type, C.p_name
where AA.id = BB.id
and CC.pid = BB.pid;
注意主句select前面的無","號