LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-16-2011, 12:15 AM   #1
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
Combine output of select statements on different tables.


Hello all,

I need to generate certain reports. The data has to be taken out from mysql database. But the problem is that the data is scattered over two different tables in a database and the table structure for both the tables is different. The tables do not have similar columns.
But there is a reference from one table to another using a key. Is there a way where in I can run "SELECT" queries on both and combine the result using the common column as key?
 
Old 11-16-2011, 12:30 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

yes you can do that with a "join". Without knowing what sql variant you are using it is not possible to point you to the correct documentation. Try searching online for something like "foosql tutorial join" where "foosql" corresponds to what you are using (eg mysql, postgresql etc).

HTH,

Evo2.
 
Old 11-16-2011, 01:25 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Original Poster
Rep: Reputation: Disabled
Thanks for the concern.

I did it this way,

SELECT * from table_A as a , table_B as b where <some condition here>;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample SQLite read, write, select, compare statements for C++ miamagoo Programming 5 06-16-2010 09:05 AM
Korn - combine select with an array lucmove Programming 3 06-09-2010 07:29 AM
Can't figure out the combine and formatting of output to a file HyperTrey Programming 11 12-12-2008 01:40 PM
Dynamically select data from MySQL tables tangle Programming 6 02-28-2006 05:48 PM
Some help with oracle select statements please! genderbender Programming 5 04-16-2005 09:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration