MySQL Forums
Forum List  »  Newbie

Multiple Records Displayed Horizontally
Posted by: Brandon Culpepper
Date: March 17, 2009 12:01PM

I have two tables

Assets: assetId | assetName

and

cadValues: assetId | year | cadValue

When INNER JOINING I of course get two records back.

1 | Truck | 1 | 2008 | $19,000
1 | Truck | 1 | 2009 | $17,000

How can I display these as one record?

example:

1 | Truck | 1 | 2008 | $19,000 | 2009 | $17,000

I have tried using the group_concat() function but it always returns BLOB.

in SQL I would use the following query to achieve these results

SELECT assets.assetId,
assets.make,
assets.model,
assets.assetNumber,
MAX(CASE cadValues.cadValue != '' THEN cadValues.cadValue ELSE 0 END) as cadValue
FROM nline_portal.assets
INNER JOIN nline_portal.cadValues ON assets.assetId = cadValues.assetId
WHERE assets.assetId = 1
GROUP By assets.assetId,assets.make,assets.model,assets.assetNumber

Any help would be greatly appreciated.

Thank you.

Options: ReplyQuote


Subject
Written By
Posted
Multiple Records Displayed Horizontally
March 17, 2009 12:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.