Question : loop results within output query

I have a page that has a query that pulls from a database (see attached graphic for database structure) a list of music events associated with a given calendar event. Each music event has the potential for multiple music events. The cfoutput generates a repeating table for each event, a column of each, contains information about the event. At this point, performers (in one of the column) outputs as a list. (see attatched graphic for example of this output. The "Musicians" list equals #performers# in the output code.

Instead of just a list like
bezalel tecnologies
matthew lipscomb

I need a table which is looped inside the cfoutput area that repeats for each record generated by the query. I need the query to generate a value that represents how many musicians are ALREADY present for each schedule + the number of musicans that are available but not already a part of the given musican event.

There is a query that creates a list of all available musicans which is used for the part of the form that adds a new music event. I also need a way to show/hide regions which will contain checkboxs or code to show a check box as checked.

if a musican is already associated the check boxes will look like  this
[ x] keep musican   [  ] delete musician from event

if the musician is not associated with the event then the check boxes will look like
[x] musican not a part of this event     [  ] add musican to this event


I know how to pass and evaluate the values ( I think)

if the conditional logic = musican already a part of event
value="keep#user_id#" /> Keep Performer

value="delete#user_id#" checked="checked" />Delete Performer

else

value="unused#user_id#" /> performer not a part of this event
value="add#user_id#" checked="checked" />add perfomer


I think this is a way to make this work

I am not sure if I should use user_id or performer_id as the identity marker
I am not sure how to build the logic that generates the values that control the cfif logic

I am not sure how to rewrite/modify the sql queries to do what I need to do


query that generates list of music events:




SELECT music.*,
performance_type.performance_desc,
(SELECT count(performer_id) from performers where music_id = music.music_id) as no_performers,
rtrim(first_name) + ' ' + rtrim(last_name) as performer
FROM (music LEFT JOIN performance_type on performance_type.performance_type = music.performance_type)
JOIN (performers LEFT JOIN users on performers.performer_id = users.user_id)
ON music.music_id = performers.music_id
WHERE music.church_id = 10 AND music.calendar_id = #calendar_id#
ORDER BY music.music_date, music_time
           
     




query that generates a list of all available musicans (used to add perfomers to new events)


     
             
   SELECT rtrim(u.first_name) + ' ' + rtrim(u.last_name) AS musician, u.user_id
   FROM users u
   INNER JOIN roles_user ru ON ru.user_id = u.user_id AND ru.site_id = u.church_id
   INNER JOIN roles r ON r.role_id = ru.role_id AND r.site_id = ru.site_id
   WHERE u.church_id = #church_id#
        AND r.role_desc = 'musician'
   ORDER BY u.first_name







Answer : loop results within output query

your description is too long to read my friend, so i don't know if this is what you need, ,but sql has an option called cross apply, which means that you perform a select statement and for each row returned, sql will invoke a function (this function may return a table by itself)
Random Solutions  
 
programming4us programming4us