给你举个例子把 ibquery1中的查询语句为: select id,name,age,address from table1 where address='上海' ibquery2中的查询语句为: select id,name,age,address from table1 where address='广州'要联合查询出idquery1和idquery2中age相等的如下: select a.*,b.* from (select id,name,age,address from table1 where address='上海') a inner join (select id,name,age,address from table1 where address='广州') b on a.age=b.age
select a.Field1,a.field2,a.field3 [a.fieldN..] from Table1 a inner join Table2 b on a.field1=b.field1 and a.field2=b.field2 and a.field3=b.field3 . . and a.fieldN=b.fieldN
SELECT * FROM ibquery1 INNER JOIN ibquery2 ON (连接语句,还有LEFT JOIN, RIGHT JOIN) ibquery1.字段名 = ibquery2.字段名 (匹配项,表1的某个属性值等于表2的某个属性值才显示) WHERE 条件(例如ID=1)(可选)table1 ID name 1 好当家 2 于伟刚 3 大鳄鱼table2 ID name 1 好当家 2 ??? 8 !!!SELECT table1.* from table1 INNER JOIN table2 ON table1.ID = table2.ID AND table1.name = table2.name结果 ID name 1 好当家
SELECT * FROM table1 JOIN table2 ON table1.ID=table2.ID
select a.*,b.* from (select id,name,age,address from table1 where address='上海') a inner join (select id,name,age,address from table1 where address='广州') b on 连接的条件
假如interbase有这函数intersect(取交集),执行即可 select * from ibquery1 intersect select * from ibquery2
select ibquery1 from table1 where ibquery1 =(select ibquery2 from table2 )
ibquery1中的查询语句为:
select id,name,age,address from table1 where address='上海'
ibquery2中的查询语句为:
select id,name,age,address from table1 where address='广州'要联合查询出idquery1和idquery2中age相等的如下:
select a.*,b.* from
(select id,name,age,address from table1 where address='上海') a
inner join
(select id,name,age,address from table1 where address='广州') b
on a.age=b.age
on a.field1=b.field1
and a.field2=b.field2
and a.field3=b.field3
.
.
and a.fieldN=b.fieldN
(连接语句,还有LEFT JOIN, RIGHT JOIN)
ibquery1.字段名 = ibquery2.字段名
(匹配项,表1的某个属性值等于表2的某个属性值才显示)
WHERE 条件(例如ID=1)(可选)table1 ID name
1 好当家
2 于伟刚
3 大鳄鱼table2 ID name
1 好当家
2 ???
8 !!!SELECT table1.* from table1 INNER JOIN table2 ON
table1.ID = table2.ID AND table1.name = table2.name结果
ID name
1 好当家
(select id,name,age,address from table1 where address='上海') a
inner join
(select id,name,age,address from table1 where address='广州') b
on 连接的条件
select * from ibquery1
intersect
select * from ibquery2