Reputation: 60
I need a bit of help here...
I'm trying to UPDATE a table which is connected to another table like the next ones:
table1
ID_Website | descr | level
100 2
104 2
105 3
And the other table:
table2
ID | URL
100 www.google.es
104 www.youtube.es
105 stackoverflow.com
I tried to write something on "descr" column with
UPDATE table1 JOIN table2
SET descr = 'something'
WHERE table1.level = '2'
AND table2.URL = 'www.google.es'
But, what it makes, is:
table1
ID_Website | descr | level
100 something 2
104 something 2
105 3
I know that the problem is in that "JOIN", because it makes no sense. But i tried to write "FROM" like i read in other posts and it returns a syntax error. Both tables where joinned directly when we created the tables and now sql doesn't let us to "INNER JOIN" them (when we use a SELECT, there's no need to do INNER JOINs).
I have no idea how to proceed... Thanks a lot!
Upvotes: 1
Views: 148
Reputation: 116498
You're missing the ON
clause in the JOIN
:
UPDATE table1
JOIN table2 ON table1.ID_Website = table2.ID
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SET descr = 'something'
WHERE table1.level = '2'
AND table2.URL = 'www.google.es'
Upvotes: 5