In a query in the database I enter the keywords, month, and year. I want to get the data according to the key words, the month and the year. For example: the word school on the date 2015-08 .
For this, I use the like
instead of =
operator because the date is complete and I want to do the search per month in a given year. The same thing is for the keyword because I can have words other than the word school in the registry.
The query is:
select * from despesas where palavraChave like "%escola%" or data like '2015-08%'
The error is:
If I do not spend any date and no word, it brings me the data and I do not want to. I only want the data if one of the fields is found. I've already used !null
, !notnull
, things like, but it does not solve.
The language is sql and the server language is php.