-2

I'm trying to improve my sql query in my website (PHP) that is currently working (it returns the value of all the varchars associated with a "LIKE" value), however, since is using "LIKE %%" is really slow to perform the tasks with more than 1,000 variables to calculate, since I'm using historical data and the "Like" is taking all the results that contains for example "06/2020", "07/2020", ETC. I don't mind to reduce the output to only 3 months of information, can someone provide me a suggestion to get only 3 months of results?

query("SELECT XXX_date, global_target FROM YYY WHERE XXX_date LIKE '%" . $monthvalue . "%';");

Where for example $monthvalue = 06/2020. Is it possible to improve the performance for example to extract data from id 800 to 1,000 instead of looking the entire values?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

1

if you want data between from-date to to-date

query("SELECT XXX_date, global_target FROM YYY WHERE WHERE OrderDate BETWEEN $from_date AND $to_date;");

Hard-code Query

query("SELECT XXX_date, global_target FROM YYY WHERE WHERE OrderDate BETWEEN #01/07/1996# AND #31/07/1996#;");
Uzair S.
  • 235
  • 1
  • 7