I have two tables : first one stores main informations and the second stores some extra informations. I need to update the first table with the help of some data stored at second table.
My SELECT statement is working
SELECT news.news_id,
news.title,
news.cat_id,
news.sub_cat_id,
news_extra.date_vision_tr
FROM news_extra
JOIN news
ON news.news_id = news_extra.news_id
WHERE news.cat_id=1 AND sub_cat_id=5 AND news_extra.date_vision_tr < CURDATE()
Than I tried UPDATE statement like this
UPDATE news SET news.sub_cat_id=8
FROM news
INNER JOIN news_extra
ON news.news_id = news_extra.news_id
WHERE news.cat_id=1 AND sub_cat_id=5 AND news_extra.date_vision_tr < CURDATE()
But its not working. Giving this error
*You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM news INNER JOIN news_extra ON news.news_id = news_extra.news_id WHERE news.' at line 2*