提交 b09e18fc authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 572: MySQL compatibility for "order by" in update statements.

上级 3120065b
......@@ -59,9 +59,10 @@ INSERT INTO TEST VALUES(1, 'Hello')
UPDATE tableName [ [ AS ] newTableAlias ] SET
{ { columnName = { DEFAULT | expression } } [,...] } |
{ ( columnName [,...] ) = ( select ) }
[ WHERE expression ] [ LIMIT expression ]
[ WHERE expression ] [ ORDER BY order [,...] ] [ LIMIT expression ]
","
Updates data in a table.
ORDER BY is supported for MySQL compatibility, but it is ignored.
","
UPDATE TEST SET NAME='Hi' WHERE ID=1;
UPDATE PERSON P SET NAME=(SELECT A.NAME FROM ADDRESS A WHERE A.ID=P.ID);
......
......@@ -17,7 +17,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>-
<ul><li>Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in
other JDBC classes.
</li><li>Issue 572: MySQL compatibility for "order by" in update statements.
</li></ul>
<h2>Version 1.4.181 Beta (2014-08-06)</h2>
......
......@@ -751,6 +751,12 @@ public class Parser {
Expression limit = readTerm().optimize(session);
command.setLimit(limit);
}
if (readIf("ORDER")) {
// for MySQL compatibility
// (this syntax is supported, but ignored)
read("BY");
parseSimpleOrderList();
}
setSQL(command, "UPDATE", start);
return command;
}
......
......@@ -788,4 +788,22 @@ insert into test1 values ('abcaaaa');
insert into test1 values ('abcaaaa');
delete from test1;
drop table test1;
@reconnect;
\ No newline at end of file
@reconnect;
drop table if exists test;
create table if not exists test(col1 int primary key);
insert into test values(1);
insert into test values(2);
insert into test values(3);
select count(*) from test;
> 3;
select max(col1) from test;
> 3;
update test set col1 = col1 + 1
order by col1 asc;
select count(*) from test;
> 3;
select max(col1) from test;
> 4;
drop table if exists test;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论