Reputation: 111
I want to run an mysql query in MS ACCESS 2007 using DoCmd.RunSql
DoCmd.RunSQL "update Table1 Join (select Table1.*, (@rn := if(@u = uname, @rn := @rn + 1, if(@u := uname, 1, 1) ) ) as rn from Table1 cross join (select @rn := 0, @u := '') params order by uname, id desc ) tt on t1.id = tt.id set Table1.flag = tt.rn;"
It showing Syntax Error.
Upvotes: 0
Views: 465
Reputation: 55816
You can't run MySQL syntax in Access this way.
The normal method to do that is to create a Pass-through query that connects to MySQL. It will pass the SQL directly to the server, thus this has to be of the dialect used by the server.
Or, of course, convert the MySQL syntax to Access SQL. Then DoCmd.RunSQL
will work.
Upvotes: 2