0

I have two tables. Table 1 (tbl_transaction) holds data pertaining to a transaction. Table 2 (tbl_optional) holds arbitrary data that may or may not accompany a transactions.

example

SELECT a.name, a.type, a.amount 
FROM Transaction AS a

Table 2 can hold 0 to n items associated with that transaction.

SELECT a.id, a.name, a.type, a.amount, b.value 
FROM tbl_transaction AS a 
   JOIN tbl_optional AS b ON a.id = b.trans_id 
WHERE "some condition here"

This will obviously return a list of result 1 to n depending on how many optional items there are.

Is there a way to create temporary columns so that only 1 result is returned.

i.e.

id, name, type, amount, value(1), value(2), value(n)
a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
Michaela Ervin
  • 652
  • 7
  • 22

0 Answers0