简体   繁体   中英

select unique row identifier in mysql for updating

in infomix i have seen queries like this

select rowid from table where condition

and for update they use the same row id

update table set field="val" where rowid=rowid

is there anything similar in mysql database

does uuid function does the same in mysql .

actually my problem is, there is no primary key in the table so when porting infomix query to mysql i need to consider all the fields in where condition . please help if there is an alternate solution ,

why not...

select  rowid  from  table  where  condition
                                      |
                                      V
update table set field="val" where condition   

If you are porting your queries from informix to mysql, why don't you modify your tables to include a primary key?

you could even name the PK rowid to maintain portability between the informix and mysql queries.

ALTER TABLE table
ADD rowid MEDIUMINT NOT NULL AUTO_INCREMENT KEY
you can use same condition for both query which you pass on first query, it returns you unique row..

try this

select  rowid  from  table  where  condition

and for update use the same condition as above instead of row id

update table set field="val" where rowid=rowid

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM