MySQL Forums
Forum List  »  Newbie

MySQL query - not sure if you can only select fields > 0?
Posted by: Tim Jones
Date: July 11, 2018 07:46PM

Hi,

I have the following example data set:

Field1, Field2, Field3, Field4, Field5
0, 0, 1.5, 3, 0
0, 0, 3, 5, 0
0, 0, 4, 2.34, 0
0, 0, 2, 2, 0
0, 0, 3.3, 4, 0
0, 0, 2, 7, 0

Field1 - Field5 are all defined as DECIMAL(3).

What I want to do is along the lines of:

Select Field1 (if any values > 0), Field2 (if any values > 0), Field3 (if any values > 0), Field4 (if any values > 0), Field5 (if any values > 0)

My resulting dataset would return the values for Field3 and Field 4.

Is that even possible? Or would I have to return all and check in my Python code?

Cheers,
Tim

Options: ReplyQuote




Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.