关于SQL 的复合查询问题 应该怎么解决?
我现在遇到了这样的问题?我有 2个表 A,B 他们同时有一个相关连的字段 ab
但是 A中有条件字段 a1 a2 a3 B中有条件字段 b1 b2
用联合查询可以这样写
UNION [ALL] SELECT * FROM A WHERE ab = '',a1 = '',a2 = '',a3 = ''
UNION [ALL] SELECT * FROM B WHERE ab = '',b1 = '',b2 = ''
但是如果用符合查询呢??
我是这么想的:
先对2个表进行ab的查询然后对查询结果进行 a1,a2,a3,b1,b2 的查询,但是不知道语句应该怎么写
--------------------编程问答-------------------- 使用left out join --------------------编程问答-------------------- 把具体的表结构,需要什么结果写出来 --------------------编程问答--------------------
--------------------编程问答-------------------- 用外连接就可以了啊
SELECT dbo.Adapter.AdpID, dbo.Connection.ConnString AS [Connection String], SelectCommand.SQLString AS [Select SQLString],
UpdateCommand.SQLString AS [Update SQLString], DeleteCommand.SQLString AS [Delete SQLString], InsertCommand.SQLString AS [Insert SQLString]
FROM dbo.Adapter INNER JOIN
dbo.Command AS SelectCommand ON dbo.Adapter.SelectID = SelectCommand.CmdID INNER JOIN
dbo.Connection ON SelectCommand.ConID = dbo.Connection.ConID LEFT OUTER JOIN
dbo.Command AS UpdateCommand ON dbo.Adapter.UpdateID = UpdateCommand.CmdID LEFT OUTER JOIN
dbo.Command AS DeleteCommand ON dbo.Adapter.DeleteID = DeleteCommand.CmdID LEFT OUTER JOIN
dbo.Command AS InsertCommand ON dbo.Adapter.InsertID = InsertCommand.CmdID
补充:.NET技术 , C#