Click here to Skip to main content
15,844,364 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is the query I have written:

select c.id, CONCAT(c.major_version, '.', c.minor_version) as versions from event_ids c where c_id in ('101') group by c_id, major_version, minor_version;

This is the result I am getting

|id  | versions|
|----|-------- | 
|101 | 0.0     | 
|101 | 1.0     | 
|101 | 2.0     | 
|101 | 3.0     |

I am trying to get a single value against a list of different values for the same entry

|id  | versions|
|----|-------- | 
|101 | 0.0     | 
|    | 1.0     | 
|    | 2.0     | 
|    | 3.0     |

How do I write the query so I get the desired result?


What I have tried:

This is the query I have written:

select c.id, CONCAT(c.major_version, '.', c.minor_version) as versions from event_ids c where c_id in ('101') group by c_id, major_version, minor_version;
Posted
Updated 7-Jan-22 5:40am
v2
Comments
Richard Deeming 5-Jan-22 4:42am    
The simple answer: don't. This is a presentation issue; you should handle it in the code which is displaying the results to the user, not the query.
Member 15489491 5-Jan-22 4:47am    
so which data structure should I use to save this result?
Richard Deeming 5-Jan-22 4:49am    
Whatever structure makes the most sense in your program.

1 solution

Which ever "structure" you use to display the results you cannot get away from the fact that the query will return your data as
|id  | versions|
|----|-------- | 
|101 | 0.0     | 
|101 | 1.0     | 
|101 | 2.0     | 
|101 | 3.0     |
It has to, otherwise how would you know that version 2.0 belongs with id 101?

As Richard has already pointed out, the place to start presenting these results in a different way is in the Presentation or UI layer. In this case you might want to consider populating a TreeView - e.g see TreeView (JavaFX 8)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900