Hi, correct your second statement where it reads PAYTMENT.JOBNO in PAYMENT.JOBNO:
select * FROM jobs INNER JOIN INVDETL ON INVDETL.JOBNO = JOBS.JOBNO INNER JOIN PAYMENT ON PAYMENT.JOBNO = JOBS.JOBNO and add a third JOIN clause to get the third table data too. Experiment with LEFT JOIN instead of INNER JOIN. Best regards Alex ----- Original Message ----- From: "srotyliano" <[email protected]> To: [email protected] Date: Sat, 01 Sep 2012 14:16:34 -0000 Subject: [firebird-support] Re: Queries for 3 or more tables > Thanks for the reply Mark. > > Using your format I tried... > > select * FROM jobs > INNER JOIN INVDETL ON INVDETL.JOBNO = JOBS.JOBNO > INNER JOIN PAYMENT ON PAYTMENT.JOBNO = JOBS.JOBNO > > Which gives me a "Not a valid SQL statement". If I remove the last join statement it runs and joins JOBS with INVDETL. So what I'm trying to figure out is how to nest all 3 statements. > > BTW - the query is entered in a SQL Builder GUI which is part of a commercial software package (DBA Manufacturing) and not sure if the limitation is in the GUI implementation or a Firebird 1.5 limitation. > > Thanks again, > > Steve > > > --- In [email protected], Mark Rotteveel <mark@...> wrote: > > > > On 31-8-2012 15:33, srotyliano wrote: > > > What is the best way to script a query for combining data from 3 or more tables ? > > > > > > ver: Firebird 1.5 > > > > Could you elaborate on what you want to achieve? Normally you would use > > INNER JOIN, LEFT JOIN etc to link up tables with conditions that > > establish which rows should be joined, eg > > > > SELECT <columns> > > FROM table1 > > INNER JOIN table2 ON table2.column = table1.column > > INNER JOIN table3 ON table3.column = table2.column > > > > (the last condition could also be table3.column = table1.column) > > > > Mark > > > > -- > > Mark Rotteveel > > > > > > > ------------------------------------ > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > Visit http://www.firebirdsql.org and click the Resources item > on the main (top) menu. Try Knowledgebase and FAQ links ! > > Also search the knowledgebases at http://www.ibphoenix.com > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > Yahoo! Groups Links > > > >
