这是我的选择声明
SELECT A.id, A.id_item, A.id_header,
IF (B.harga > 0, B.harga,'') AS kadar,
IF (B.harga > 0, A.kuantiti,'') AS kuantiti,
IF (B.harga > 0, B.harga * A.kuantiti,'') AS harga
FROM undi_bq A, jkh_item B WHERE A.id_item = B.id AND A.id_header = '0'
我在这里要做的是我想格式化我的选择语句的结果,以便
if ('B.harga > 0')
i will show value for columns 'kadar','kuantiti' and 'harga'
别的
all these three column will be empty
select 语句工作正常,但我只是想知道是否有办法简化 IF 语句,这样我就不必为每一列重复它。
*顺便说一句:Kadar = 价格,Kuantiti = 数量,Harga = 价格