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

My where clause is returning the opposite of what I want

这是我的查询。

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

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

如果 sp.is_published = 1 是一个字符串,您需要将它放在刻度中 IE sp.is_published = '1'