The query seems to be easy enough to convert as I have very specific requirement, if it exists just update else insert. But I am having really hard time converting it..probably because of multiple joins it is using. There is a catch to it though, there is no primary key.I would really appreciate it if someone take a crack at it and make my life easier ... :-)
There are only three columns for the table
ASSET_ASSOCIATION
-----------------
ASSET_ID | ASSET_FIELD_ID | ASSET_ASSOCIATED_ID
10 46 15
12 46 37
10 21 8
Query I am using is
.....
Is there any hope for me ?? Would really appreciate any help .....
http://dev.mysql.com/doc/refman/5.6/en/replace.html
REPLACE
works exactly likeINSERT
, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index , the old row is deleted before the new row is inserted.
No primary key or unique index, no REPLACE
, full stop.
A table without a primary key is (almost always) a huge mistake. Get in touch with the DBA (or someone with sufficient privilege) and let him/her know there is no primary key on the table. S/he will add the primary key without you asking for it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.