mysql - How to fetch Distinct Title from the GROUP_CONCAT as Left Join without repeating other tables' data? -


i've got table of values this:

table:     prop_feat type       feat appliances gas range appliances fridge interior   hardwood flooring 

i'm trying display type once features below:

appliances

gas range, fridge

interior

hardwood flooring

these values empty need left join table. i've searched everywhere! how should writing mysql display results this? have far isn't quite doing it. (i know.. not left join.. )

select *   (select group_concat( distinct concat ('', type, '', prop_feat.feat, '')     order type asc separator ' '  ) prop_feat prop_feat.id_prop = '$page'  )  feat properties id_pg = '$page' 

any appreciated!

edit

this whole query.. i've got whole bunch of joins. making type/feature issue difficult.

select *, group_concat(concat('<tr><td>', style, '</td><td>', beds, '</td><td>', ba, '</td><td>', sq_ft, '</td><td>', rent, '</td><td>', dep, '</td></tr>')      order beds desc separator '') unit,  (select      group_concat( distinct concat ('<h4>', type, '</h4><div>', prop_feat.feat, '</div>')          order type asc separator ' '  )     prop_feat     prop_feat.id_prop = '$page'  )  interior  properties  inner join prop_units on prop_units.id_prop = '$page' left join prop_intro on prop_intro.id_prop = '$page'   left join prop_hours on prop_hours.id_prop = '$page'   id_pg = '$page' group type 

properties has: name, address, city, prov, postcode, phone (display 1 property - basic info)
prop_units has: beds, bath, square feet, rent, deposit, style
prop_intro: title, text (description of place)
prop_hours: sunfrom, sunto, monfrom, monto, etc (times open during week)
prop_feat: property features has hardwood flooring, need sort type , display type once.. if possible!

edit edit - using instead

$info = mysql_fetch_array(mysql_query("select *, group_concat(concat('<tr><td>', style, '</td><td>', beds, '</td><td>', ba, '</td><td>', sq_ft, '</td><td>$', rent, '</td><td>',if(dep='','','$'), dep, '</td></tr>')      order u_order asc separator '') unit properties  inner join prop_units on prop_units.id_prop = '$page' left join prop_intro on prop_intro.id_prop = '$page'   left join prop_hours on prop_hours.id_prop = '$page'   id_pg = '$page'"));  $check = mysql_query("select type, group_concat(concat('<tr><td>', feat, '</td></tr>') separator '') featlist prop_feat id_prop = '$page' group type"); 

you need use group by clause because group_concat() aggregate function.

select  title, group_concat(feat) featlist    prop_feat group   title 

output

╔════════════╦═══════════════════╗ ║   title    ║     featlist      ║ ╠════════════╬═══════════════════╣ ║ appliances ║ gas range,fridge  ║ ║ interior   ║ hardwood flooring ║ ╚════════════╩═══════════════════╝ 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -