Jump to content

Recommended Posts

Here's my current query, I can't figure this out:

 

SELECT   conf_review_fields.fieldid    AS fieldid,
         conf_review_fields.fieldtype  AS fieldtype,
         conf_review_fields.parentid   AS parentid,
         conf_review_fields.fieldvalue AS fieldvalue
FROM     conf_review_fields,
         conf_review_form
WHERE    conf_review_form.topid = ?
         AND conf_review_form.fieldid IN (conf_review_fields.fieldid,conf_review_fields.parentid)
ORDER BY conf_review_form.fieldorder ASC

 

The relevant database structure for conf_review_fields and conf_review_form

 

CONF_REVIEW_FIELDS

fieldid  	mediumint(    	   	 
fieldtype 	tinyint(3)	  	  	 
parentid 	mediumint(  	  	  	 
fieldvalue 	varchar(150)

 

CONF_REVIEW_FORM

topid  	mediumint(  	    	   	 
fieldid 	mediumint(	  	  	 
fieldorder 	smallint(5)

 

 

Running the above query with ? = 1, I get the following results:

 

fieldid 	fieldtype 	parentid 	fieldvalue
1 	1 	0 	Clarity of Objectives
2 	1 	0 	Conceptual/Theoretical Rigor
13 	3 	10 	Publish with major revisions
12 	3 	10 	Publish with minor revisions
11 	3 	10 	Publish as is
10 	3 	0 	Recommendation
15 	3 	10 	Not suitable
14 	3 	10 	Revise and resubmit

 

 

What needs to happen though, is that when the fieldtype = 3, with the parentid = 0, it then has other fields that reference that parentid (for example, all of the 10s).

 

Is there a way to modify the query, using Group_concat or something else, that can pull those values into something I can loop through whenever a fieldtype = 3 and parentid = 0 is found?

Link to comment
https://forums.phpfreaks.com/topic/157371-solved-need-help-with-larger-query/
Share on other sites

fieldid    fieldtype    parentid    fieldvalue
1    1    0    Clarity of Objectives
2    1    0    Conceptual/Theoretical Rigor
10    3    11,12,13,14,15    Recommendation

 

So this way, when the fieldtype = 3 (a dropdown menu), I can then build out the option values.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.