MERGE INTO PAGEEDITCONTROL A
USING (SELECT
1585 AS PAGEID
, admin AS EDITUSER
,sysdate AS EDITDATE
FROM DUAL) B
ON (A.PAGEID = B.PAGEID)
WHEN MATCHED THEN
UPDATE SET
A.EDITUSER = B.EDITUSER
,A.EDITDATE = B.EDITDATE
WHEN NOT MATCHED THEN
INSERT (
A.PAGEID
,A.EDITUSER
,A.EDITDATE
)VALUES(
B.PAGEID
,B.EDITUSER
,B.EDITDATE
)
将Oracle合并查询转换为MySQL查询
原标题:
问题回答
INSERT INTO
pageeditcontrol (pageid, edituser, editdate)
VALUES ( 1585 , admin , sysdate())
ON DUPLICATE KEY UPDATE
edituser = values(edituser),
editdate = values(editdate);
MySQL 有一个类似的结构,看起来不像更新插入,而更像插入: INSERT ... ON DUPLICATE KEY UPDATE
(请参阅 MySQL 参考手册)。
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding