TheTitans Posted October 30, 2008 Share Posted October 30, 2008 I have two columns in a mysql table called evo_chain_id and evo_parent_id. They look like this: I would like to check if two or more values in evo_parent_id are the same. If they are, execute one function. If not, execute another function. So, for example, because 265 appears in there more than once, the first function would execute. I think I'm suppose to do something with the SQL COUNT() function, but I'm not too sure how that works. Could some help me? Link to comment https://forums.phpfreaks.com/topic/130683-finding-duplicate-values-in-database/ Share on other sites More sharing options...
predator12341 Posted October 30, 2008 Share Posted October 30, 2008 if you want them to be unique just assign the column auto_increment if you dont want them to be unique do a select call to search the table against the id before you call a function then depending on the mysql_num_rows you get back you can then decided to call which function. Regards Mark Link to comment https://forums.phpfreaks.com/topic/130683-finding-duplicate-values-in-database/#findComment-678490 Share on other sites More sharing options...
GingerRobot Posted October 30, 2008 Share Posted October 30, 2008 To find which ID's are duplicated, you could use this: SELECT evo_parent_id,COUNT(evo_parent_id) as cnt FROM yourtable GROUP BY evo_parent_id HAVING cnt > 1 Link to comment https://forums.phpfreaks.com/topic/130683-finding-duplicate-values-in-database/#findComment-678541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.