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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.