MySQL coalesce for some null, not all null -
I have a MySQL query that checks an employee schedule db and (thanks to any previous stackover flow question) Any day that the user is not working as "no work", so if the user is not working on Thursday, the query is filled in that date, although the date does not appear in the original result set (And so I do not fill it in Dta those spaces through the PHP script).
The problem now is that if the user is now checking the program for two weeks, it shows "no work" throughout the week if there are no results, then the script "sorry, this No schedule for the week ", so the user does not mistake it to think that he has closed in the week and knows to check back later.
So the question is: What is the best query syntax for something like:
Choose if calculation (*)> 0 {COALESCE (gooddata, nulldata) as edita etc. From dates between xxx and yyy
from the timetable if all these rows are blank or 0).
I tried to add a column for a count and tried to skip the script output and leave it after a repetition, but then on good weeks it would end even after a recursion Goes, so I'm getting frustrated.
I'm sure if I want to take a step back, then I can get a script to do, but I'm very excited that if there is a way to do this in the query that the other null rows are organized There must be at least one line non-null value to do
Oh no, join an inner selection, one of them is conditional? Are you serious? How to use a simple union to fill the vacancy ??
SELECT real_week_data UNION SELECT fake_empty_week;
This union will make unique results for you, what you really want ..
Comments
Post a Comment