gpt4 book ai didi

mysql - 我的 where 子句返回的与我想要的相反

转载 作者:行者123 更新时间:2023-11-30 22:15:23 24 4
gpt4 key购买 nike

这是我的查询。

select sp.name, spi.sku, sum(spi.price), count(sp.name), spi.in_stock, spi.price, sp.is_published, spi.is_reorderable
from shop_product_category spc
inner join shop_product_category_xref spcx
on spc.shop_product_category_id = spcx.shop_product_category_id
inner join shop_product sp
on sp.shop_product_id = spcx.shop_product_id
inner join shop_product_item spi
on spi.shop_product_id = sp.shop_product_id
inner join shop_order_item soi
on spi.shop_product_item_id = soi.shop_product_item_id
where (spc.shop_product_category_id in (1316))
and sp.is_published = 1
group by sp.name
order by count(sp.name) desc

它返回的一切都很好,除了我希望它返回 sp.is_published = 1 的行因此是 where 子句。但要获得所需的输出,我必须将当前的 where 子句更改为 sp.is_published <> 1所以问题是,为什么 <> 1 返回带 1 的行,而 =1 返回带 0 的行。谢谢

最佳答案

如果 sp.is_published = 1 是一个字符串,你需要把它放在 ticks IE sp.is_published = '1'

关于mysql - 我的 where 子句返回的与我想要的相反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38467043/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com