mysql - Using Distinct in a subquery -


how display fields of row based on 1 field distinct (i.e there should no duplicates field)

suppose there's table called office_roles fields , data below

name   department   designation  john   marketing    executive john   sales        executive john   pr           executive 

so want end result display fields in row 1 john (distinct)

output -

john marketing(or sales) (or pr) executive

i thinking of like

select * office_roles name =(select distinct name office_roles); 

how correctly ? want order , limit number of results per page on end result...

you can't have variable number of columns query. 1 thing can concatenate values together:

select name, group_concat(department) departments,        group_concat(designation) designations office_roles o group name 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -