This topic is locked

Master-Detail Relationships

5/7/2007 2:29:39 PM
PHPRunner General questions
G
garivera author

I have been able to set-up a Master-detail relationship between 2 tables (Table A and Table B ). I have used inner join to view information from Table B to Table A. Everything OK so far.
Table B has several records that relate to Table A based on a unique ID number (IN below) that ties the two Tables together. The problem is that Table A only adds the first related record from Table B to A, then record 2 from Table B added to A on another line, then record 3 added to Table A on another line, etc. I need "all" related records from table B added to A in one consolidated record. How would I do this?
select TableA.IN,

TableA.ID,

TableB.DR,

TableB.TM

from TableA inner join TableB

where (TableA.IN=TableB.IN)
TableA has

IN (int)- Key

ID
TableB has

PID (int) - Key

IN

DR

TM
Using MySQL 5.0

Sergey Kornilov admin 5/7/2007

It works the way INNER JOIN queries work.
You can use GROUP BY to consolidate table B records.
Take a look at this article for more info:

http://www.webcheatsheet.com/sql/interacti...sql_groupby.php