How do I delete all the duplicate records in a MySQL table without temp tables

Add Unique Index on your table: ALTER IGNORE TABLE `TableA` ADD UNIQUE INDEX (`member_id`, `quiz_num`, `question_num`, `answer_num`); Another way to do this would be: Add primary key in your table then you can easily remove duplicates from your table using the following query: DELETE FROM member WHERE id IN (SELECT * FROM (SELECT id FROM … Read more

Short unique id in php

Make a small function that returns random letters for a given length: <?php function generate_random_letters($length) { $random = ”; for ($i = 0; $i < $length; $i++) { $random .= chr(rand(ord(‘a’), ord(‘z’))); } return $random; } Then you’ll want to call that until it’s unique, in pseudo-code depending on where you’d store that information: do … Read more

How does PostgreSQL enforce the UNIQUE constraint / what type of index does it use?

create an index and not assume that the values are unique It is safe to assume that values are unique, if you have a unique index defined. That’s how unique constraints are implemented (at the time being, and probably in all future versions as well). Defining a UNIQUE constraint does effectively the same (almost, see … Read more