Webmaster Blog

Webmaster Resources

SQL: Select table entries with the same value

Let’s say you got a table with lots of entries that have the same value and you want to safe each entry in an array even if it’s a “duplicate”, you can do it with a simple SQL query:

 

$query = $db->query("SELECT * FROM $db->tablename where exists ( SELECT tablerow_name FROM $db->tablename) ") ;

 

I hope that helps a bit :)