list records from a concatenated search query

5 posts by 3 authors in: Forums > CMS Builder
Last Post: November 30, 2011   (RSS)

By Deborah - November 29, 2011

Another table merging challenge. I don't know how (or if its possible) to query related records for a table based on a field created by a CONCAT query.

I have a master list page for 'artists'. Clicking on the selection for a specific artist, I'd like to see the 'merchandise' list page with listings that match the artist selected.

The tables are:
'artists'
'merchandise'

The 'merchandise' table contains an 'artist_name' select list field that uses this query:

SELECT num, CONCAT(first_name," ",middle_name," ",last_name) FROM `<?php echo $TABLE_PREFIX?>artists`
ORDER BY first_name

The merchandise table is storing the artist_name as the record num, not the concatenated name, so I can't use 'artist_name' for my search.

Can this even be done? If so, any pointers would be greatly appreciated. Thanks in advance!

~ Deborah

Re: [Deborah] list records from a concatenated search query

By zip222 - November 29, 2011

amazingly I just learned how to do this earlier today on a site I am working on, and I got it to work the first time. here is what my query looks like...

SELECT num, CONCAT(city,', ',state)
FROM `<?php echo $TABLE_PREFIX ?>facilities`


The only difference I see is the use of single quotes in mine versus doubles in yours.

Re: [zip222] list records from a concatenated search query

By Deborah - November 30, 2011

zip222,

Thanks for posting the alternate code. Actually, both versions work for me. What I need to do is one step further, which Jason has addressed in the next reply. I appreciate your help.

~ Deborah

Re: [Jason] list records from a concatenated search query

By Deborah - November 30, 2011 - edited: November 30, 2011

Jason,

I had just set everything up successfully using CONTACT for value and label. I understand now from your post that this is not the desired method, due to updates to the names. I'll install the upgrade and give it a go (your #2 suggestion).

Thanks for the helpful info and wish me luck!

~ Deborah