EdgarsK Posted June 11, 2009 Report Share Posted June 11, 2009 Sveiki, Mana tabula: id,title,my_order Ieraksti: ---------------------------- 1|Cooler|1 2|Divide|2 3|Clock|3 Vēlos nomainīt Id 2 ar id 3 tātad man būtu jādara sekojoši ? update tabula set my_order=my_order+1 where my_order=2 update tabula set my_order=my_order-1 where id=3 un otrādi ? Šobrīd izmantoju šo, bet nesaprotu kapēc man vislaik my_order aiziet pa nullem... Quote Link to comment Share on other sites More sharing options...
otoman Posted June 13, 2009 Report Share Posted June 13, 2009 Ko īsti TU rezultātā gribi ieraudzīt? Kaut ko šādu: 1|Cooler|1 2|Divide|3 3|Clock|2 ? Izpildot Tavus UPDATEs šķiet, ka tā arī vajadzētu izskatīties, ja protams, MY_ORDER lauks nav char tipa... Quote Link to comment Share on other sites More sharing options...
kechums Posted June 13, 2009 Report Share Posted June 13, 2009 Grūti pateikt, ko tu vēlies, tad tu prasi vienu, kverijā atkal tu gribi nomainīt kaut ko citu... No visa izrietošā es saprotu, ka tu vēlies nomainīt abas vērtības (id, my_order), tad kverijam vajadzētu šādam darboties. UPDATE tabula SET my_order=my_order+1, id=id+1 WHERE title='Divide' UPDATE tabula SET my_order=my_order-1, id=id-1 WHERE title='Clock' 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.