1

I feel really stupid on this one...

I have multiple tables users1, users2, users3 with the same structure : Name, address, city, zip. I need to display all the info in a single table (and later in a csv file).

SELECT * From users1, users2, users3 

doesn't work, it concatenates the info horizontally like :

row 1 > name1 address1 city1 zip1 name2 address2 city2 zip2...

What i want is to have all the rows from users1, followed by all the rows from users2, followed by all the rows from users3. In other words, if each of my table is 20 rows, I want a 60 rows output. How can I do that?

2
  • 1
    @Santhosh's answer is correct but you should consider combining them into one table. Commented Nov 13, 2013 at 17:28
  • I have no use for a single table, the tables are dynamically generated/removed/modified... I just need output sometimes. but thanks for yor comment! Commented Nov 13, 2013 at 17:36

1 Answer 1

4

You can do UNION or UNION ALL

SELECT * FROM USERS1
UNION ALL
SELECT * FROM USERS2
UNION ALL
SELECT * FROM USERS3
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.