I'm just cutting my teeth on writing MySQL statements and I feel like I'm really close with this one—but it's not quite there.
I'm essentially trying to query the database to find documents where tv1, tv2, and tv3 are equal to various values. For instance, find all documents where tv1="dessert" tv2="cookies" tv3="chocolate"
I'd like to be able to get the information about the document (longtitle, contentid, etc) as well as the values of the various TVs if possible.
SELECT *,GROUP_CONCAT(prefix_site_tmplvar_contentvalues.value) AS tvvalues
FROM prefix_site_tmplvars
JOIN prefix_site_tmplvar_contentvalues
ON prefix_site_tmplvars.id = prefix_site_tmplvar_contentvalues.tmplvarid
JOIN prefix_site_content
ON prefix_site_content.id = prefix_site_tmplvar_contentvalues.contentid
WHERE name IN ("tv1", "tv2", "tv3" )
GROUP BY prefix_site_tmplvar_contentvalues.contentid
HAVING tvvalues LIKE ......
This SELECT statement is close to what I want to accomplish, but I ended up with all of the TV values as:
[name] => food_type
[name] => flavor
[value] => cookies
[value] => chocolate
How could I adjust my statement so that I could have:
[contentid] => 14
[flavor] => chocolate
[food_type] => cookies
[meal] => dessert
Thank you!
[ed. note: bartleby last edited this post 14 years, 2 months ago.]