MySQL Forums :: Newbie :: Help collating multiple rows from multiple tables into a single row


Advanced Search

Help collating multiple rows from multiple tables into a single row
Posted by: Mike Heien ()
Date: November 14, 2009 04:09PM

That is probably a horrible description of what I need.

What I have is a two tables, one that contains "field" information. This table was designed to allow a web site administrator a high level of configuration for collecting data.

Table Layout:

id int(10)
type varchar(255)
name varchar(255)
tips text
visible tinyint(1)
required tinyint(1)
searchable tinyint(1)
options text
fieldcode varchar(255)

The other table simply contains the values for these configurable fields:

id int(10)
user_id int(11)
field_id int(10)
value text

Now what I want to do is create a tmp table based off of search criteria... but I want to collate the user data into a single row using the fieldcodes from the first table as columns. Because as you can imagine, if the admin has created 13 fields each user has 13 entries in the "values" table.

Can this be done with SQL or does it have to be done using multiple steps with a secondary processing language (in my case php)?

Thank you very much for your help.



Edited 1 time(s). Last edit at 11/14/2009 05:52PM by Mike Heien.

Options: ReplyQuote


Subject Written By Posted
Help collating multiple rows from multiple tables into a single row Mike Heien 11/14/2009 04:09PM
Re: Help collating multiple rows from multiple tables into a single row Rick James 11/18/2009 09:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.