Kent Parker wrote:
> Hi guys,
> 
> I'm stuck on a MySQL query problem.  I want to put the result of two
> ids in the same table into one row, based on an id in a third row.

Do you mean an id in a third column?

> "SELECT * FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t1.fld1 =
> t2.fld1 LEFT JOIN table3 AS t3 ON t2.fld2 = t3.fld2 LEFT JOIN table4
> AS t4 ON t2.fld2 = t4.fld2 GROUP BY fld1"
> 
> For each row fld1 has only one value hence the GROUP BY, but fld2 can
> have two values.  What I want is to have any content from table3 and
> table4 that has a fld2 that is linked to fld1 included in each row of
> the query.  Then I want to sort on fields from both table3 and table4,
> so creating 2 queries is not going to help (or is it?).
> 
> I've searched the net but can't find out how I might do this.  Any
> pointers would be greatly appreciated.

Could you draw a grid showing what kind of result you're trying to 
produce? It's hard to tell from this description what kind of result set 
you're expecting to get. We probably need to know what the data looks like.

Are you trying to do something like going from

t1.f1 | t2.f2
-------------
1     | a
1     | b

to

t1.f1 | t2.f2
-------------
1     | a,b

-- 
Tim Oliver
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to