-2

I have the following query :

 update event
    set event.Paid = payment.amount
    from event, payment
    where payment.event_id = event.eid

The above query gives following 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 event, payment where payment.event_id = event.eid' at line 3

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
code123
  • 39
  • 7
  • 1
    Which database product are you using? MySQL (as stated in your error message, I guess it's that) or sql-server as in your tags? – deHaar Mar 09 '20 at 10:00
  • I am using phpmyadmin – code123 Mar 09 '20 at 10:03
  • You might need see this.. https://stackoverflow.com/questions/1068447/update-with-two-tables – jay bhut Mar 09 '20 at 10:03
  • 1
    _I am using phpmyadmin..._ phpmyadmin is a tool not a dbms – B001ᛦ Mar 09 '20 at 10:04
  • Does this answer your question? [Update with two tables?](https://stackoverflow.com/questions/1068447/update-with-two-tables) – Amira Bedhiafi Mar 09 '20 at 10:05
  • @SandraGuilepZouaouiZandeh still getting 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 event e, payment p where e.eid = p.event_id' at line 3] – code123 Mar 09 '20 at 10:25

1 Answers1

2

You join clause is wrong anyway

You should not use the implicit join syntax based on comma separated table name and where you should use explicit join syntax (for mysql)

update event 
INNER JOIN payment ON  payment.event_id = event.eid
set event.Paid = payment.amount
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107