LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 01:15 AM   #1
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

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, 01:30 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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, 02:25 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:05 AM
Korn - combine select with an array lucmove Programming 3 06-09-2010 08:29 AM
Can't figure out the combine and formatting of output to a file HyperTrey Programming 11 12-12-2008 02:40 PM
Dynamically select data from MySQL tables tangle Programming 6 02-28-2006 06:48 PM
Some help with oracle select statements please! genderbender Programming 5 04-16-2005 10:08 AM


All times are GMT -5. The time now is 02:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration