select * from 3 tables

Posted on 2010-01-12
Medium Priority
Last Modified: 2012-05-08
select * from table1,table2,table3  doesnt work

and want to order by table1.id
Question by:rgb192
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26297446
how these table are related ?
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 26297451
can you clarify how the output should look like?
1 table behind the other, or side-wise.
please show data samples.
LVL 82

Expert Comment

ID: 26297463
Hello rgb192,

Don't work ? You don't have the expected result(s) ?
Do you know the primary key and/or foreign key of the tables ?


Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 41

Accepted Solution

Sharath earned 1000 total points
ID: 26298270
Please answer all the open questions from others. Did you try like this?

select *
 from table1
cross join table2
cross join table3
order by order by table1.id
LVL 12

Assisted Solution

by:Chris M
Chris M earned 1000 total points
ID: 26301193
If you want to query all three tables and these tables have identical structures, then run the following statement:

select * from table1
union select * from table2
union select * from table3
order by id;

The way your query sounds, it's like you want to pick related data from these three tables.
Then the previous answer from Sharath should be fine.

Author Closing Comment

ID: 31676349

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question