-1

GUYS i just want a query of mysql . I have a database inside there are 3 tables . Each tables is having the same column names.

Table A:


CITY  
 A    
 G    
 Y     


TABLE B:

CITY 
 F    
 G   
 I    


TABLE C:

CITY 
 B 
 N   
 M

you can check above three tables column names are same
so i just want another table where only one column must be present using this data.
need this kind of table

CITY
A
G
Y
F
G
I
B
N
M

This table is nothing but collection of above tables PLs if anyone knows Query using mysql then pls pls pls reply

Thank you in advance

4

1 回答 1

0

You can union them.

SELECT city FROM TableA
UNION ALL
SELECT city FROM TableB
UNION ALL
SELECT city FROM TableC

union all just combines the data of all tables. union (without all) filters duplicates and therefor is a bit slower, so don't use it unless you need to.

I do wonder though, why you have three different tables of cities in the first place. Why not have one?

于 2013-11-12T09:56:49.540 回答