0

I have 2 tables: Table1 (entry, x, y) Table2 (entry, x, y)

I want to update Table1.position1, sot it = Table2.Position1 where entries are the same(there are different entries in both tables, but some are the same)

So what I have tried to do:

update Table1 SET Table1.x = Table2.x where Table1.entry=Table2.entry;

But got error:

Unknown column 'Table2.entry' in 'where clause'

So then I tried to do another query:

update Table1 SET Table1.x=(select x from Table2) inner join Table2 on Table1.entry=Table2.entry;

But again got 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 'inner join Table2 on Table1.entry=Tab' at line 1

Any of the answers in google didn't gave me satisfactory result, so I hope someone can help. Thank you.

1

1 Answer 1

0

The syntax in MySQL is:

update Table1 t1 join
       Table2 t2
       on t2.entry = t1.entry
    set t1.x = t2.x;
Sign up to request clarification or add additional context in comments.

1 Comment

How many times are you going to answer this question again and again without marking it a duplicate?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.