In this article I describe how you can get the position (row and column) of a Widget in a Cell, or to be precise, how to get row and column of a QWidget in a QTableWidget. This is specially useful in case you have a button or any other widget and you want to perform a task specific to that widget when it is pressed or triggered in any way.
Continue reading “How to Get the Position of a Widget in a Cell (QTableWidget)”Handling Duplicate Records in SQL
This happens a lot (to me at least 🙂 ) so I decided to make a note here!
Following SQL script will allow you to SELECT duplicate records in a given table.
SELECT * FROM my_table WHERE some_field IN (SELECT some_field FROM my_table GROUP BY some_field HAVING COUNT(some_field) > 1)
This code actually finds all the records in a table named “my_table” which have the same value for a field (or column) named “some_field” in more than 1 records which is specified in the final clause COUNT(some_field) > 1
To delete (remove) duplicate records you only need to change “SELECT *” to “DELETE”.
DELETE FROM my_table WHERE some_field IN (SELECT some_field FROM my_table GROUP BY some_field HAVING COUNT(some_field) > 1)