Skip to content
Advertisement

Conditional Concatenation of SQL Query results

I’d like to show the results of a query concatenated with their self based on a value.

I have this query

which shows the list of available location for a booking platform, based on what the user is typing.

enter image description here

This is the results list:

The inner join table results is the following

Results of above query

as you can see there are different level_depth for each entry of the table.

I would like to CONCAT all the entries with level_depth=3 with the name of their id_parent and showing all the entries with level_depth=2 without any concatenation.

The above results should become:

Advertisement

Answer

This requires a left join by id_parent for level_depth 2. You should end up with something like this:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement