I am doind this query UPDATE trans t JOIN accounts ON(t.user_id = a.id) JOIN (SELECT user_id FROM trans GROUP BY user_id HAVING SUM(amount) > 0.00005460 ) tt ON(tt.user_id = a.id) GROUP BY a.id SET t.paidout=1 and 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 'GROUP BY a.id SET t.paidout=1' at line 6 Any help would be apreciated
Hi Asso, In your query you have syntax error. In UPDATE statement GROUP BY must be in sub-query. Thats why syntax error is occurred. Your final non error query is: UPDATE trans t JOIN accounts ON(t.user_id = a.id) JOIN (SELECT user_id FROM trans GROUP BY user_id HAVING SUM(amount) > 0.00005460 ) tt ON(tt.user_id = a.id) SET t.paidout=1
A database is an organized collection of data. The data are typically organized to model relevant aspects of reality in a way that supports processes requiring this information.....