日期:2014-05-17 浏览次数:20869 次
SELECT *
FROM a t1
INNER JOIN b t2 ON t1.id=t2.aid
INNER JOIN c t3 ON t2.id=t3.bid
INNER JOIN d t4 ON t3.id=t4.cid
select * from a
select * from b where aid in (select id from a)
select * from c where bid in (select id from b)
select * from d where cid in (select id from c)
--字段名写错了,参考如下:
select * from a
select * from a INNER JOIN b ON a.id=b.aid
select * from a INNER JOIN b ON a.id=b.aid INNER JOIN c ON b.id=c.bid
select * from a INNER JOIN b ON a.id=b.aid INNER JOIN c ON b.id=c.bid INNER JOIN d ON d.cid=c.id
CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
AS
BEGIN
SELECT * FROM A
SELECT * FROM B
INNER JOIN A
ON B.ID=A.ID
SELECT * FROM C
INNER JOIN B
ON B.ID=C.ID
INNER JOIN A
ON B.ID=A.ID
SELECT * FROM D
INNER JOIN C
ON D.ID=C.ID
INNER JOIN B
ON B.ID=C.ID
INNER JOIN A
ON B.ID=A.ID
END
GO
create proc proc_test @id int
as
set nocount on
select * from a where id=@id
select * from a inner join b on a.id=b.aid where a.id=@id
select * from a inner join b on a.id=b.aid
inner join c on b.id=c.bid where a.id=@id
select * from a inner join b on a.id=b.aid
inner join c on b.id=c.bid&nbs