I have a table such as:
id name ref_id order data_obj -- ---- ------ ----- -------- 1 Sam 0 15 [binary data] 2 Jack 0 20 [binary data] 3 Sue 0 25 [binary data] 4 Sam2 1 - [no data] 5 Sue2 3 - [no data] 6 Sam3 1 - [no data]
The idea is that I have more columns other than data_obj which can be common, so I don't want to insert them again, just want to insert a reference id to the same data.
Is it possible to write a query and select this:
1 - Sam - binary data from id 1 4 - Sam2 - binary data from id 1 6 - Sam3 - binary data from id 1 2 - Jack - binary data from id 2 3 - Sue - binary data from id 3 5 - Sue2 - binary data from id 3
Please note that I'm ordering according to column named order and there's no actual data for this column for referenced rows.