The closest I can come up with is this select statement:
Code:
select concat(Product.ProductID," ",Name," ",MessageType) from Product,Message
where Product.ProductID=Message.ProductID;
This is basically a join from two tables (Product and Message) and would produce something like this:
Code:
ID Name MessageType
ABC001 TestA MessageA
ABC002 TestB MessageB
ABC002 TestB MessageC
ABC003 TestC MessageA
ABC003 TestC MessageC
You could return the result of this select statement into an array and go through a loop where so long as the ID is the same as the previous to only print the MessageType. Once the ID changes then you can start a new line where you begin the printing with the ID, Name, and MessageType.
Hope that helps.
Casey