August 13th, 2013, 12:24 PM
Mysql problem with inner join
I have a Joomla website and trying to update the category for some articles, based on tag selection.
There are two tables: table_items and table_tags
table_items has two columns: id and categoryID
while table_tags has two columns: tagID and itemID
These two tables are connected through id and itemID.
I have the following sql query
INNER JOIN `table_tags`
WHERE (`table_items`.`categoryID`=5) AND (`table_tags`.`tagID`=63);
...but I get this error:
#1064 - 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 `table_items` INNER JOIN `table_tags` ON `table_items`.`id`' at line 3
Any help will be highly appreciated! Thanks!
August 13th, 2013, 05:18 PM
the error message tells you exactly where the sql error is -- at the word FROM
Originally Posted by astraxan
so you cannot say UPDATE... SET... FROM... (which is actually microsoft sql server syntax)
mysql syntax is slightly different
could i ask you to look it up in the mysql manual?
August 13th, 2013, 05:26 PM
I actually just found solution without using INNER JOIN! Anyway thanks for the help!
SET `categoryID` = 24
( SELECT `itemID` FROM `table_tags`
AND `catid` = 5 )