şö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)
-
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...
-
I took the first jab in August 15 around 10:30 in the morning. no pain or nausea or dry mouth, I have been intermittent fasting since 2017 ...
-
I haven't eaten around 67 hours and I am feeling pretty good, like I said after 48 hours I started another 48 hours of fast and come thi...
No comments:
Post a Comment