Tag Archives: sql

DELETE all duplicates from TABLE

If we have a long table with thousands of records with some duplicate contents and we want to trim it down to the bare essentials (no duplicates), here’s one (of several) way of doing it: For this, assume we have: – a table called “emails”, with fields: id_email, email – the table has several records… Read More »

Preventing SQL injection in PHP/MySQL with PDO

This is a bit old but i wanted to add it here so it stays on record. SQL injection is the action to inject SQL code in web forms to perform a site attack and disrupt its services. For a better definition, go read wikipedia here (it even has some code for you to test… Read More »

insert into table using a select from another table

Following the update with data from another table, i am leaving this for quick reference. To insert data into table2 from table2: insert into table2 (field1,field2,field3) select table1.field1,table1.field2,table1.field3 from table1 (all the above is on the same line) We can make this as complex as needed.