How to select from multiple tables without a JOIN

0 votes
What is the simplest way to choose data from two tables and have them show up as distinct rows rather than being joined? Both tables have fields that are the same or comparable, and I want to do an aggregate operation on them, such as averaging all the rows from both tables that occurred in the same month.

I have two tables, for instance, one of which displays transactions from one system and the other of which displays transactions from a different system. Is it possible to extract each transaction from the two tables as a distinct row? I would like the return to include 50 rows if table 1 contained 20 records and table 2 contained 30 records.
Sep 11 in Database by Kithuzzz
• 11,640 points
41 views

1 answer to this question.

0 votes

Try this:

SELECT ...
FROM (
    SELECT f1,f2,f3 FROM table1
    UNION
    SELECT f1,f2,f3 FROM table2
)
WHERE ...

I hope this helps you.

answered Sep 12 by narikkadan
• 19,680 points

Related Questions In Database

0 votes
1 answer

How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
293 views
0 votes
0 answers
0 votes
0 answers

How to create a table from select query result in SQL Server 2008

I tried to build a table from ...READ MORE

Sep 2 in Database by Kithuzzz
• 11,640 points
37 views
+2 votes
1 answer

How to export data from MySql to a CSV file?

If you are using MySql workbench then ...READ MORE

answered Jan 4, 2019 in Database by Priyaj
• 58,080 points
515 views
0 votes
1 answer

Want a command to be executed in Salt only if a directory is empty

You should consider using this inside your ...READ MORE

answered Jun 12, 2018 in DevOps Tools by Damon Salvatore
• 5,980 points
755 views
0 votes
1 answer

Creating A New MySQL User In Amazon RDS Environment

AWS RDS security groups documentation (a common ...READ MORE

answered Jul 18, 2018 in AWS by Priyaj
• 58,080 points
1,396 views
0 votes
1 answer

Using conditional to execute a command in salt

You can use unless inside your state ...READ MORE

answered Jul 23, 2018 in Other DevOps Questions by DareDev
• 6,890 points
820 views
0 votes
1 answer

SQL SELECT from multiple tables

Try this: SELECT p.pid, p.cid, p.pname, c1.name1, c2.name2 FROM ...READ MORE

answered Sep 16 in Database by narikkadan
• 19,680 points
20 views
0 votes
1 answer

How to extract only the year from the date in sql server 2008?

To obtain the year from the given ...READ MORE

answered Sep 15 in Database by narikkadan
• 19,680 points
42 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP