Wednesday, 2 October 2013

SQL Join - multiple tables in same row

SQL Join - multiple tables in same row

We're developing a PHP page to create some reports. We're using data from
a database that is "populated" by a third-party application.
We need to execute a query to select "tickets" between a period and to
select other data from another table.
Example:
//Select tickets closed between dates
SELECT *
FROM ticsummary
WHERE resolution_date between #07/04/2013# AND #08/04/2013#;
//Result
Ticket Resolution_date
61968 07/04/2013This (above) is working great. However we need to add a
content that is in another table named "ticFieldVals". The content from
this table is:
ticId fieldId intVal numVal strVal
61968 1 4 Voz NULL NULL
61968 2 3 Closed NULL NULL
61968 3 2 NULL NULL
61968 100 2 NULL NULL
61968 103 NULL 300.000 NULL
61968 85253767 0 NULL NULL
61968 73913495 1 NULL NULL
61968 23260488 NULL NULL
61968 83015458 1 NULL NULL
61968 33742201 1 NULL NULL
61968 57589628 1 NULL NULL
61968 91660570 NULL NULLSo I need to execute a "join", to have
both of these tables in just one table. However the content of
ticFieldVals there is a lot of rows, and I need to put all together in
same row.
I'm sure if you can totally understand, but any help is greatly appreciated.

No comments:

Post a Comment