0

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.

2
  • When writing portable code, ANSI SQL is my number one tip. (The SQL Validator can quickly verify ANSI SQL syntax, developer.mimer.com/validator/parser200x/index.tml, a great time-saver when writing portable code.) Commented Jan 29, 2016 at 10:43
  • What does error say? Commented Jan 29, 2016 at 11:33

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.