Home > Database > Mysql Tutorial > body text

expdp导出两表关联后的数据

WBOY
Release: 2016-06-07 16:48:26
Original
1176 people have browsed it

有两张表t1、t2 t1表结构为 id、name、age t2表结构为 id 我们关联语句是这样的select t1.* from t1,t2 where t1.id = t2.id; 我

有两张表t1、t2

t1表结构为

id、name、age

t2表结构为

id

我们关联语句是这样的select t1.* from t1,t2 where t1.id = t2.id;

我们现在就是需要取这部分关联查询后的数据,对于数据量很大的情况我们建议还是用数据泵。

但是需要有两条原则:

第一,查询的全部字段来源同一张表,例如我们这里查询结果都是t1表中的字段

第二,查询的表与其他表关联值是唯一的,实际上就是其他表的记录不是重得的,否则结果不准确

保证这两条原则后,,我们可以改写成如下SQL:

select t1.* from t1 where exists

(select 1 from t2 where id = t2.id);

因此我们的parfile中可以写成这样

tables=t1

query=t1:"where exists (select 1 from t2 where id = t2.id)"

这里一定要记住,where 后面的t1的字段千万不要写成t1.id这样的形式,直接就写id,否则会报错误的标识

本文永久更新链接地址:

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!