|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
MySql Sub Queries...
While i was searching for a solution to my problem i found out that my current mysql version doesnt support sub queries. I am stuck with a problem whose solution i can think of only as a sub-query.
I'll eliminate all useless details and narrate the problem. Tablename: links id(PK) url 1 abc 2 xyz 3 abc 4 cde 5 tyu and the list goes on Notice the duplicates in the url field (for eg. id1 and id3 where url = 'abc'). Can someone please tell me some way of REMOVING the duplicates however leaving any ONE of them? The current MYSQL query i thought of using subqueries was; delete from links where id IN (select id from links group by url having count(*) >= 2) The inner query displays all the id's of links who have 2 or more url entries. The outer query deletes the row with that id. Can someone tell me a better option WITHOUT subqueries? Thanks |
|
#2
|
||||
|
||||
|
You could always work up a little script that first does the subquery and stores the results in an array, then goes through the array (or joins it for use in an "IN" clause) to do the actual deletion.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > MySql Sub Queries... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|