首页 > 代码库 > sql

sql

合并不同行数的两个表格的数(A表里的一个值a,与另B表的行数同步,即新表行数与B一样,由a+B表查出的各行组成):

以下三种效果一样,第三种效果最佳:

1.select sV,PD,Sh,Pro
from
(Select sV From Sy where sN=‘Cur‘ ) t1,
(Select PD,Sh,Pro From P ) t2

2.select * from (Select  sV From Sywhere sN = ‘Cur‘ )  left join    (Select PD, Sh, Pro From   P) on 1 = 1

3.select sV,PD,Sh,Pro From Sy    left join P on 1=1  where sN = ‘Cur‘

sql