I have a table in MySQL that has the following form:
ID | StartDate | EndDate | Value
---------------------------------------
01 | 01/01/2015 | 01/01/2016 | 100
I am using this table to save data for a chart created in PHP. The only thing is that the graph needs the data to be of this form:
Date | Value
------------------
01/01/2015 | 0
01/01/2016 | 100
The value
for StartDate
is always going to be 0, but for EndDate
it needs to be the Value
one mentioned in the table.
So what I'm trying to create is a closing queryWHERE ID =
that can output the results in the form of the second table. There is no problem creating another column called for example StartValue
where the 0 is stored.
Is it possible to do this?
You don't indicate the type of grouping that is required (since multiple values for the same dates are to be expected), perhaps it would be better if you provided the actual schema of your table and load examples along with a result that you would expect. In any case, with one
UNION
you get what you indicateIf you want to filter, filter on both queries