So I have a table where I have column A, B, C,D. Column A has values which have corresponding multiple values in column B.I need to check if all the values in column C and D are null for the column B values.
Column A | Column B | Column C | Column D |
---|---|---|---|
100 | 5 | 0 | 3 |
100 | 6 | 1 | 5 |
100 | 7 | null | null |
If you observe here. Column A has same value. Consider that a single shop. Consider Column B to be the products of a shop. Column C can be the price and Column D may be the discounts.
In the above table if I want to find out the shop which has no cost set for any product and no corresponding discount. then if I use Is Null for column C and Column D it will give me 3rd row. But I have other products from Shop 100 having cost and discounts set.
My expectations:
I want to fetch the shops for which all the cost and discount are null for all the products.
-
where all the column values are null for Column C and D,
-
all the column values are not null for Column C and D,
2
Answers
you mean something like this (assuming it’s SQL)
And
I would suggest using
concat
andconcat_ws
in MySQL.If any of the values are null
concat
returns null.In your case would be.
See example