pistou
pistou

Reputation: 2867

Regroup mySQL query results in a single CSV file

I don't know if a solution to my problem exists.

I'm trying to regroup results from two similar queries, without using anything else than mySQL.

Here are my requests :

SELECT id, type as objet, decret as type, resume as synthese FROM projets
SELECT id, type as objet, decret as type, resume as synthese FROM articles

Obviously, I get an ambiguous error if I try

SELECT id, type as objet, decret as type, resume as synthese FROM articles, projets

I'd like to merge theses results in order to export it in a single CSV file, without using Excel manipulation or so.

Thanks

Upvotes: 0

Views: 122

Answers (1)

Doon
Doon

Reputation: 20232

try union

SELECT id, type as objet, decret as type, resume as synthese FROM projets
UNION
SELECT id, type as objet, decret as type, resume as synthese FROM articles

http://dev.mysql.com/doc/refman/5.0/en/union.html

Assuming the columns are the same in both tables.

Upvotes: 2

Related Questions