Delete duplicate users by Username with this query.. DELETE a FROM tbl_user a INNER JOIN tbl_user b ON a . user_name = b . user_name WHERE a . id <> b . id
Find duplicate users by name with this query.. SELECT a . name FROM tbl_users a INNER JOIN tbl_users b ON a . name = b . name WHERE a . id <> b . id LIMIT 0 , 30
Returning the last row of each GROUP BY in MySQL with WHERE clause: "SELECT * FROM foo WHERE id IN ( SELECT Max ( id ) FROM foo WHERE value = 'XYZ' GROUP BY u_id ) LIMIT 0 , 30"
Simplest way to fetch second max salary & nth salary "select DISTINCT ( salary ) from employee order by salary desc limit 1 , 1" Note: limit 0 , 1 - Top max salary limit 1 , 1 - Second max salary limit 2 , 1 - Third max salary limit 3 , 1 - Fourth max salary