şöyle bir durumumuz var. table1 deki field1 i bir artırıp bi kaç satır insert etmek istiyoruz ve "select field1+1 from table1" dediğimizde field1 herhangi bir sebepten dolayı null olduğu için selectimizin sonucu null geliyor.
bu durumda ne yaparız. sonuç basit "select ifnull(field1,1)+1 from table1" dediğimizde field1 olursa 1 değilse kendisi gelir ve 1 artırılıp istenen değer alır. bu problemle karşılaştığımda biraz uraştırdı buda ayrı bir çözüm ki benim kullandığım bu çünkü durumu asıl kurtaran bu oldu siparis _id sini bir artırmam gerekiodu ve bu sipariş id si en büyük sipariş id si olması gerekiodu.
"SELECT ifnull(max(siparis_id)+1,1) from siparisler where user_id=?user_id;"
bu sayede kullanıcının en son verdiği sipariş id si bir artırılıp yeni sipariş id si olarak kullanılır oldu.
Subscribe to:
Post Comments (Atom)
speed test glasgow
at first test upload was 20mbps, something broke it now it gives 0.07 but I am happy with 129 download and price is 16 £
-
I know its been a long time I have not write anything. because I have not learn or done any new things. I dont want to write regular meaning...
-
After iphone 16 I wanted to test an android and looks like sony xperia 10 VI is nice, which is 6.1 inches, but it was narrow and longer than...
-
in .net 2 if you want to show your application in system tray . you need to add notify icon to your application and set the "ShowInTas...
No comments:
Post a Comment