duangong0690 2019-03-14 10:42
浏览 51

哪里是null或不是equalent值不返回mysqli中的记录

I am trying to fetch the records from two tables.

1 - tokens 2 - transactions

In both tables there is same column user_id and tokens table has transaction_id. I am trying to get all transactions which has relation with token. I am trying following

select sum(`amount`) as aggregate 
from `tokens` 
where `user_id` in (15, 713, 49, 58, 60) 
and exists 
    (select * 
    from `transactions` 
    where `tokens`.`transaction_id` = `transactions`.`id` 
    and (`custom` != 'BB' or `custom` is null)
    )

When I change operator in my query like ``customis not null then I am getting the record, but not means query will show the record of 'BB'.

I have searched about it and found a good sentence from this thread

NULL Cannot be compared to any value using the comparison operators. NULL = NULL is false. Null is not a value. The IS operator is specially designed to handle NULL comparisons.

So in custom I have only one value which is BB and another is NULL.
My above query is not working.

Can someone kindly guide me how can I resolve the issue?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题