I pulled off some SQL voodoo the other day that I thought was pretty neat. I don't know, maybe this is obvious to someone with more database experience than I have, but I thought I would write it down so I remember it later. The problem, in simplified form, is something like this
(
Read more... )
Comments 9
Reply
Reply
SET @val := 0;
UPDATE Vals
SET Order = (@val := @val + 1)
ORDER BY Value;
To condense it into one statement, you'll need to use a subquery and join:
UPDATE hyuga
JOIN
(SELECT val, @num := @num + 1 rownum FROM hyuga, (SELECT @num := 0) temp ORDER BY val) sorted
ON sorted.val = hyuga.val
SET row_number = rownum;
You can't just do one top-level JOIN because you can't use ORDER BY in a multi-table UPDATE - at least in MySQL. Dunno about other DBMS.
Should be fast, but I haven't benched it.
Reply
Um...so talk to you sometime in the next week or so.
Peace.
- Brandon
Reply
Reply
Alas, most FFVI costumes are not trivial to do well, and I already have one cosplay commitment for 2009. Nor do I know yet whether or not I'll be going to Otakon next year. So it's far too early for me to be able to make a commitment. But keep me posted; I am interested.
Reply
Maria told me you have long and blonde hair, so I was thinking of you as either Edgar or Setzer!!
As far as the costumes themselves go, I have no problem making them myself for other people. I'm pretty good with cosplay (don't know if you saw Maria's photos from the weekend) so as long as I have a definite yes from someone, I can start planning.
Again, it's reaaally early so no rush or anything, but yay I'm glad you're interested, and I'll keep you updated!!
Reply
Anyways, if you're willing to help with the costume that's definitely a plus, though I'd want to work on it some too, or at least pay for materials if nothing else. I still don't even know if I'll be able to go to Otakon next year though, so yeah, like you said, it's early. Is it okay if I add you to my friends list to keep in touch?
Reply
Leave a comment