Friday, 15 January 2010

mysql - update the result of select statement -


After

I managed to create a selection in the selection statement

  Please l.rank, r Choose from rank (as795_sh404sef_urls) * Where NEWURL regexp 'Itemid \ = 108' and Max (ID0 Group) having OLDURL by the & # 39; & gt; (where the rank = 0 group as795_sh404sef_urls, depending on OLDURL *) L.oldurl = r.oldurl included as L on R;  

What I need to do is swap the rank around it. Another word will be update every time that l.rank becomes r.rank and r.rank . l.rank .

The first row in the first row is the result of the first 0 and the second 2. I want to have an alternative after that update will be selected and the first will be 2 and the second 0.

I hope this makes any sense.

I'm not sure what you are looking for, but what is it? You do not want "select *" on the selected statement in the update, but a select ID After that you will have a list of those IDs you want to update. What I did was to fix the update syntax (assuming MS-SQL) and only to see a list of IDs. I have left your selected criteria alone, assuming that you are already correct :)

set rank = 0 where in id (as795_sh404sef_urls from SELECT id WHERE newurl REGEXP 'Itemid \ = 108 'and rank & lt;> 0 and oldurl =' zumba-gold-8.html 'Max (ID)

being grouped by OLDURL

No comments:

Post a Comment