TOP Comments

+1
Well. Gary I don't know, but I think that this second example will work only with MySQL database. And you haven't written in which database this should work. I am shure that this won't work in SQL Server. I have checked in SQL Server manual msdn.microsoft.com/en-us/library/ms177523.aspx and I haven't found this kind of syntax you hav written.

I've got one better example of UPDATE ;)



update 
    gracze 
set
    drewno = drewno + drewno_kop * 2 + s.drewno
    ,kamienie = kamienie + kamienie_kop * 2 + s.kamienie
    ,krysztal = krysztal + krysztal_kop * 2 + s.krysztal
    ,siarka = siarka + siarka_kop * 1 + s.siarka
    ,klejnoty = klejnoty + klejnoty_kop * 1 + s.klejnoty
    ,rtec = rtec + rtec_kop * 1 + s.rtec
    ,zloto = zloto + zloto_kop * 1000 + s.zloto
from
    (
        select
            sum(ps.drewno) drewno
            ,sum(ps.kamienie) kamienie
            ,sum(ps.krysztal) krysztal
            ,sum(ps.siarka) siarka
            ,sum(ps.klejnoty) klejnoty
            ,sum(ps.rtec) rtec
            ,sum(ps.zloto) zloto
            ,ps.id_gracza
        from
            (
                select
                    id_gracza
                    ,sum(zloto_plus) zloto
                    ,sum(drewno_plus) drewno
                    ,sum(kamienie_plus) kamienie
                    ,sum(krysztal_plus) krysztal
                    ,sum(rtec_plus) rtec
                    ,sum(klejnoty_plus) klejnoty
                    ,sum(siarka_plus) siarka
                from
                    bohaterowie
                group by 
                    id_gracza
                
                union 
                
                select
                    b.id_gracza
                    ,sum(a.zloto) zloto
                    ,sum(a.drewno) drewno
                    ,sum(a.kamienie) kamienie
                    ,sum(a.krysztal) krysztal
                    ,sum(a.rtec) rtec
                    ,sum(a.klejnoty) klejnoty
                    ,sum(a.siarka) siarka
                from
                    bohaterowie b
                inner join
                    bohaterowie_artefakty ba
                on
                    ba.id_bohatera = b.id_bohatera and ba_pozycja < 15 and ba_pozycja > 0
                inner join
                    artefakty a
                on
                    a.id_artefaktu = ba.id_artefaktu
                group by
                    b.id_gracza
                
                union
                
                select
                    m.id_gracza
                    ,sum(case 
                        when 
                            m.glowny_budynek = 1 
                        then 
                            500
                        when 
                            m.glowny_budynek = 2 
                        then 
                            1000
                        when 
                            m.glowny_budynek = 3 
                        then 
                            2000      
                        when 
                            m.glowny_budynek = 4 
                        then 
                            4000
                        end) zloto
                    ,sum(mz.drewno) drewno
                    ,sum(mz.kamienie) kamienie
                    ,sum(mz.krysztal) krysztal
                    ,sum(mz.rtec) rtec
                    ,sum(mz.klejnoty) klejnoty
                    ,sum(mz.siarka) siarka
                from
                    miasta m
                inner join
                    magazyny_zasobow mz
                on
                    mz.typ_miasta = m.typ_miasta
                group by
                    m.id_gracza                    
                
                union
                
                select
                    id_gracza
                    ,0 zloto
                    ,0 drewno
                    ,0 kamienie
                    ,sum(case
                            when
                                magiczny_staw = 1 
                            then
                                2
                            else
                                0
                        end
                        )krysztal
                    ,0 rtec
                    ,0 klejnoty
                    ,0 siarka
                from
                    miasta      
                group by
                    id_gracza   
            ) ps
        group by
            ps.id_gracza
    ) s
where
    s.id_gracza = gracze.id_gracza


avatar

jmail

  • May 29, 2010, 6:08am
+1
Thanks, interesting.
Waiting for more complicated stuff.

What about Ruby?
avatar

paker

  • April 29, 2010, 4:17am
+1
Useful case, thanks!
avatar

tapin13

  • April 29, 2010, 1:33am
0
yeah, it's a standalone, but probably too outdated already…
avatar

t0lkman

  • July 29, 2013, 3:17am
0
Is this a standalone image or what? I cannot get mysql libraries to work with django and I see where I may need to retrieve packages online…
avatar

pkjones

  • June 26, 2013, 3:08pm
0
I am having an issue using the mysql library? I can connect to mysql, but not using pylons/django once I made the change to the connection of the helloworld project.
avatar

pkjones

  • June 14, 2013, 2:15pm
0
not yet, sometimes it works though, but sometimes being reset each minute;[
avatar

t0lkman

  • November 25, 2011, 9:31pm
0
Не нашли нового решения?
avatar

R3Y

  • November 25, 2011, 4:39pm
0
Could you please translate this to Windows?
avatar

thirilog

  • November 21, 2011, 4:28pm
0
Yeah I've noticed it too, sometimes I have to run it each 3-4 hours ;(
It looks like OSX somehow resets SMC values occasionally…
avatar

t0lkman

  • October 3, 2011, 11:44am
0
Hey, nice one! Maybe I won't return my MBA anymore now ;)

I was wondering, do you have a way to make this change permanent? I have to run the script each time I start or wake the MBA up.

Cheers!
avatar

etique

  • October 3, 2011, 11:25am
0
Thanks for sharing…
avatar

arohatech1

  • June 10, 2011, 3:42am
0
Saying that Java is good because it works on all platforms is like saying anal sex is good because it works on all genders
— Anonymous
avatar

t0lkman

  • January 6, 2011, 9:27pm