0

I am trying to run a query and get a result based on 2 dates. When using the query below I keep getting this error.

You have an error in your SQL syntax; check the manual that corresponds to the right syntax to use near 'BETWEEN '2017-12-10' AND '2017-12-30')' at line 1

Below is the query I am trying to use. I am not sure what I am doing wrong here.

Any help would be really appreciated!

SELECT * FROM checkout WHERE id = 10 AND (BETWEEN '2017-12-10' AND '2017-12-30')
json
  • 11

2 Answers2

1

You are not providing the column name for between

column_name BETWEEN value1 AND value2

https://www.w3schools.com/sql/sql_between.asp

1

Add a column name before "between"

SELECT * FROM checkout WHERE id = 10 AND ( `columnname` BETWEEN '2017-12-10' AND '2017-12-30')

This will help you

Lalit Mohan
  • 464
  • 3
  • 16