Forum Moderators: coopster
TABLE: news
news_id ¦ title ¦ content
ex: 1 ¦ This is the title ¦ This is the content etc...
TABLE: ratings
id ¦ total_votes ¦ total_value
ex: News1 ¦ 4 ¦ 17
I'd like to use left join for news.news_id and ratings.id but of course for the news articles I have the added "News" before the id for the ratings table key.
$query = mysql_query("SELECT news.news_id, ratings.total_value, ratings.total_votes, title, content
FROM news LEFT JOIN ratings
ON news.news_id = ratings.id");
How do I prepend 'News' to the join statement?
LEFT JOIN ratings
ON news.news_id = REPLACE(ratings.id,'News','')
< Parallel discussion here:
[webmasterworld.com...] >
[edited by: tedster at 7:46 pm (utc) on Jan. 6, 2009]