我想问一下,当它为null时如何输出0? 我试过IFNULL和COALESCE,它不起作用。
$this->db->select('produk_tb.kode_produk, produk_tb.nama, kategori_tb.nama as namakategori');
$this->db->from('produk_tb');
$this->db->join('penjualan_detail_tb', 'produk_tb.kode_produk = penjualan_detail_tb.kode_produk', 'inner');
$this->db->select_sum('penjualan_detail_tb.jumlah','jual');
$this->db->join('pembelian_detail_tb', 'produk_tb.kode_produk = pembelian_detail_tb.kode_produk', 'inner');
$this->db->select_sum('pembelian_detail_tb.jumlah','beli');
$this->db->join('kategori_tb', 'produk_tb.kode_kategori = kategori_tb.kode_kategori', 'inner');
$this->db->group_by('kode_produk');
$kontak = $this->db->get()->result();
$this->response($kontak, 200);
提前致谢
答案 0 :(得分:1)
尝试以下
while(flag == True):
try:
price = input("Enter the price: ")
price = float(price)
flag = False
#price must be positive
if float(price) < 0:
print("Invalid input for the new price.")
flag = True
#check for 2 decimal places
decimal = str(price)
decimal = decimal.split(".")
if len(decimal[1]) != 2:
print("Invalid input for the new price.")
flag = True
答案 1 :(得分:0)
$ this-&gt; db-&gt; select('select COALESCE(field_name,0)as field_name_alias');
$这 - &GT; DB-肽从( 'your_table');
尝试这个