mapleleaf Posted May 30, 2010 Share Posted May 30, 2010 I have an articles table with a tag field and a theme field.(and other fields) The theme field takes a single theme_id. Themes are in their own table. I want to pull all the articles that have duplicated the theme name in their tags. Tags are comma separated. It seems like it would be easy but.... Pseudo: SELECT * FROM articles, themes WHERE themes.theme like '%articles.tags%' Tx Link to comment https://forums.phpfreaks.com/topic/203385-subquery-question/ Share on other sites More sharing options...
fenway Posted May 30, 2010 Share Posted May 30, 2010 First problem -- no join condition. Second problem -- what's being stored in the "theme" column?? I'm confused. Link to comment https://forums.phpfreaks.com/topic/203385-subquery-question/#findComment-1065483 Share on other sites More sharing options...
riwan Posted May 31, 2010 Share Posted May 31, 2010 Well, I think your field is reversed, the one on the left side of LIKE should be articles.tags I would think below is what you want SELECT * FROM `articles` , themes WHERE articles.tags LIKE CONCAT( '%_', themes.theme, '_%' ) Link to comment https://forums.phpfreaks.com/topic/203385-subquery-question/#findComment-1065533 Share on other sites More sharing options...
mapleleaf Posted May 31, 2010 Author Share Posted May 31, 2010 Riwan that is what I needed. thanks. theme was the theme name by the way fenway. Tx to both Link to comment https://forums.phpfreaks.com/topic/203385-subquery-question/#findComment-1065556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.