Split SQL statements

Posted by eaZy on Stack Overflow See other posts from Stack Overflow or by eaZy
Published on 2009-03-17T15:29:33Z Indexed on 2010/05/13 6:44 UTC
Read the original article Hit count: 147

Filed under:
|
|

Hello, I am writing a backend application which needs to be able to send multiple SQL commands to a MySQL server. MySQL >= 5.x support multiple statements, but unfortunately we are interfacing with MySQL 4.x.

I am trying to find a way (hint: regex) to split SQL statements by their semicolon, but it should ignore semicolons in single and double quotes strings.

http://www.dev-explorer.com/articles/multiple-mysql-queries has a very nice regex to do that, but doesn't support double quotes.

I'd be happy to hear your suggestions.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql