Am looking for a way to have a query like:
Mysql:
Example: IF SELECT COUNT(column_XX) WHERE column_XX = value_XX FROM table_XX is greater that zero (0) then SELECT everything or SELECT * FROM that table_XX WHERE column_XX = value_XX and return all data ... else return 'nothing found' or just ZERO (0)
In simple words,I want to select all the data from a table column if all the values in the column is greater than zero else select only the values>=1 and return all the values.
Which Magic can be applied here to have it done in a SINGLE QUERY?... am really Stuck thanks.
You could try like this:
SELECT * FROM table_XX
WHERE column_XX = (
SELECT column_XX FROM table_XX
WHERE column_XX = value_XX GROUP BY column_XX HAVING COUNT(column_XX) > 0
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With