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 Quote Link to comment 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. Quote Link to comment 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, '_%' ) Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.