MySQL Forums
Forum List  »  Newbie

Re: Update existing value on column using a database MySql version 8.0.17
Posted by: Chevy Mark Sunderland
Date: April 30, 2021 02:05AM

I’ve update the table using this query… what do you think?

UPDATE t3 t
JOIN (
	SELECT
		r1 AS id,
		DATA,
		sID 
	FROM
		( SELECT DATA, sID, ROW_NUMBER() OVER ( PARTITION BY DATA ORDER BY sID ASC ) AS r1 FROM t3 ) AS t3 
	WHERE
		r1 = 1 UNION ALL
	SELECT
		r2 + 1,
		DATA,
		sID 
	FROM
		( SELECT DATA, sID, ROW_NUMBER() OVER ( PARTITION BY DATA ORDER BY sID DESC ) AS r2 FROM t3 ) AS t3 
	WHERE
		r2 = 1 
	ORDER BY
		DATA DESC,
		sID DESC 
	) q 
	SET t.rowNumber = q.id 
WHERE
	t.sID = q.sID;

Options: ReplyQuote


Subject
Written By
Posted
Re: Update existing value on column using a database MySql version 8.0.17
April 30, 2021 02:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.