sql - How do you think I should write a query?(MySQL) -


i trying write query fetch data 3 tables know how write query exactly.

i trying merge 3 tables. in first table has id , data_name, second table data_id, option_id , property , third table user_id, data_id.

for example:

first table id -- data_name 1 - veri1 2 - veri2 3 - veri3  second table  data_id-- property -- option_id  1 ---------- blue ---- 1 1 ---------- cold ---- 2 2 ---------- gray ---- 1 2 ---------- hot  ---- 2 3 ---------- green---- 1 3 ---------- cold ---- 1  third table user_id ---  data_id    1  -------  2    2  -------  3    3  -------  1  

this should output.

user: 1 data: veri2 properties: gray - hot 

what should sql query?

this 1 should requested

select third.user_id user, first.data_name data, group_concat(second.property separator ' - ') third_table third left join (first_table first, second_table second) on third.data_id = first.id , second.data_id = first.id group third.user_id 

group_concat , group by cooperate list of properties per user.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -