0

The issue I am having is the following:

Table1.FieldA is unique where as the Table2.FieldA field is not.

When I run the following:

SELECT Table1.Numbers, Table2.Numbers
FROM Table1, Table2
WHERE Table1.ID = Table2.ID

I get mutiple records like so:

ID Name Numbers
125 John Doe 555, 556, 557
125 John Doe 686, 687

I know this is happening bc there are multiple records in Table2.ID which match the unique record in Table1.ID

My question is, how can I merge the returned results into one row when I have multiple matches.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by novedturn
0

I think you can use join, inner join, left join, right join or cross join,
ex,
select a.numbers,b.numbers
from table1 as a inner join table2 as b on a.id = b.id

0

Still stuck here. Here is what I have come up with so far:

$query = "SELECT
Table1.*,
Table2.A,
Table2.B,
Table2.C,
Table2.D,
Table2.E
FROM Table1
INNER JOIN
Table2 ON Table1.A = Table2.A

Issue is that there are multiple matches for some instances, like so:

Table1.A value = 1777 (only once since it is a UniqueID)
Table2.A value = 1777 (3 records with this ID value)

So I will get 3 records returned since Table1.A matches 3 records in Table2.A. I want to merge the 3 records in Table2 into 1 record and then match that with Table1 where the UniqueID is the same. Make sense?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.