niche Posted November 30, 2020 Share Posted November 30, 2020 (edited) this script deletes dupe rows when table_key is a column: DELETE t1 FROM obssum_history t1 INNER JOIN obssum_history t2 WHERE t1.id < t2.id AND t1.table_key = t2.table_key how would I do that when table_key is a column alias? Already tried something like this (when table_key is NOT contained in the table): USING CONCAT(col1, col2) AS table_key DELETE t1 FROM obssum_history t1 INNER JOIN obssum_history t2 WHERE t1.id < t2.id AND t1.table_key = t2.table_key didn't work. Edited November 30, 2020 by niche Link to comment Share on other sites More sharing options...
niche Posted December 1, 2020 Author Share Posted December 1, 2020 (edited) Turns out this is the answer: WHERE t1.id < t2.id AND CONCAT(t1.col1,t1.col2) = CONCAT(t2.col1,t2.col2) Duh! Edited December 1, 2020 by niche Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now