[thelist] MySQL: from lookup tables to flat table

kasimir-k evolt at kasimir-k.fi
Wed Apr 19 12:50:59 CDT 2006

Dear List,

perhaps something simple, but today the answer just keeps escaping me.

I have tables
persons - personId, name
fields - fieldId, fieldName
types - typeId, typeName
persons_x_fields - personId, fieldId
persons_x_types - personId, typeId

A person may belong to 0 or more fields and be of 0 or more types.

What kind of query would give a table like this:
personId, name, [field1, field2, ...], [type1, type2, ...]

i.e. field and type columns are comma separated lists which can also be 


More information about the thelist mailing list