关于SQL文合并的问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:16:37
SQL1:
select a,b from table1;
SQL2:
select c from table2 where d = a and e = b;

怎么合成一个SQL
太复杂了吧。
我的目的只是要取得c而已

select c from table2,table1 where table2.d=table1.a and table2.e=table1.b

可以直接返回新插的记录的,只要执行
declare @id int
insert...
select @id=get什么id() --这个函数比@@id更可靠
select...where fid=@id
就行了

v沛v的语句是可行的:
select c from table2,table1 where table2.d=table1.a and table2.e=table1.b
呵呵