
oralce么?
select A姓名,A电话,wm_concat(B卡号) 卡号 from 表A A,表B B where A姓名=B姓名 group by A姓名,A电话
试试 select aid from table1 as a join table2 as b where ( apid = bpid or apid like '%,||bpid or apid like '%,||bpid||,%' or apid like bpid||,%') and bname like '%def%')
没太明白你AB的具体设置
还有表里数据的设置
不过你的意思我明白了
这样吧
假设你有两张表
表AA和表BB
然后X和Y是两个表里都有的属性
假设符合两表的X相等并且Y也相等这个条件时,能唯一确定一条记录
那么就可以写
select
AX,AY,BX,BY
from
AA
A,BB
B
where
AX=BX
and
AY=BY;
select里也可以加别的表里的属性段
你想查的东东~
mysql支持多个库中不同表的关联查询,你可以随便链接一个数据库
然后,sql语句为:
select from db1table1 left join db2table2 on db1table1id = db2table2id
只要用数据库名加上""就能调用相应数据库的数据表了
数据库名表名
扩展资料mysql查询语句
1、查询一张表: select from 表名;
2、查询指定字段:select 字段1,字段2,字段3from 表名;
3、where条件查询:select 字段1,字段2,字段3 frome 表名 where 条件表达式;
例:select from t_studect where id=1;
select from t_student where age>22
4、带in关键字查询:select 字段1,字段2 frome 表名 where 字段 [not]in(元素1,元素2);
例:select from t_student where age in (21,23);
select from t_student where age not in (21,23);
5、带between and的范围查询:select 字段1,字段2 frome 表名 where 字段 [not]between 取值1 and 取值2;
例:select frome t_student where age between 21 and 29;
select frome t_student where age not between 21 and 29;
假设:
数据库DB_A,表Table_A
数据库DB_B,表Table_B
那么联合查询写入如下:
select
from
DB_AdboTable_A a
inner join DB_BdboTable_B b on aID=bID
以上就是关于数据库 多表联合查询全部的内容,包括:数据库 多表联合查询、Access select where 数据库查询 多表联合查询、数据库联合主键查询等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)