1

I'm using mysql db from oracle (latest version 8.*). I'm using node js with express. I have several tables with the exact same layout. All using an auto_increment id and some columns. For the index page. I need the fetch all data from multiple tables. I have the following tables: beers (100 rows), non_alcoholic_beers(7 rows) and red_wines(50 rows).

Accordingly to the Oracle documentation a simple: SELECT * FROM table1, table2; or SELECT * FROM table1 join table2; should suffice. It's works kinda....

But if I do this I get 52+K records. A lot of duplicates thus. I only expect 157 records.

A simple: 'SELECT * FROM table1;' works perfectly.

Can anyone show some light on this matter? Thanks in advance

B.Kingma
  • 79
  • 1
  • 5

1 Answers1

1

If your tables are not related to each other (no foreign key) and you just want to get all the results combined you should use UNION. It merges the result of queries . You can try it like

Select * from table1 
UNION 
Select * from table2
Madhur Bhaiya
  • 28,155
  • 10
  • 49
  • 57
Abdullah Razzaki
  • 972
  • 8
  • 16