1
これは私のクエリです。私のwhere句は、私が望むものの逆を返しています
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
それは私が= 1つのしたがって、WHERE句sp.is_publishedどこで行を返すようにしたい場合を除きうまくすべてを返します。しかし、現在のwhere節を sp.is_published <> 1
に変更する必要があります。これはなぜですか?<> 1は1で行を返し、1は1で行を返します。おかげ
mysql'は、あなたが「上がらない句by' 'グループから列を省略することができます'ので、おそらく、望ましくない動作を得ているダニtを 'select'節に入れます。そのフィールドを 'group by'句に追加して、それがあなたの問題を解決しないかどうかを確認してください... – sgeddes
多分1は文字列ですか?あなたは単一のダニでそれを囲むように試みましたか? IE 'sp.is_published = '1''? – Zak
@sgeddes私はちょうどそれを試みたが、それはまだ0のものではなく、1のものを返す:/考えてくれてありがとう。 – Bartonb12