LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Combine output of select statements on different tables. (https://www.linuxquestions.org/questions/linux-newbie-8/combine-output-of-select-statements-on-different-tables-913767/)

linuxlover.chaitanya 11-16-2011 12:15 AM

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?

evo2 11-16-2011 12:30 AM

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.

linuxlover.chaitanya 11-16-2011 01:25 AM

Thanks for the concern.

I did it this way,

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


All times are GMT -5. The time now is 09:32 PM.