Mysql where between and equal to?

I have a mysql function

SELECT * FROM `stats` WHERE BETWEEN '2011-01-03' AND '2011-01-01' AND `email`='sarah@sarah.com' AND `city`='New York' AND `location`='New York' AND `date` GROUP BY action

However I can't seem to get it working, it works if I take out the BETWEEN '2011-01-03' AND '2011-01-01' but not with it in, how can I make this function work?


WHERE BETWEEN '2011-01-03' AND '2011-01-01'

needs a column name to be compared. Is it the date column?

Then your query should look like this:

SELECT * FROM `stats` WHERE `date` BETWEEN '2011-01-01' AND '2011-01-03' AND `email`='sarah@sarah.com' AND `city`='New York' AND `location`='New York' GROUP BY action


add the name of date field and


change the order

date BETWEEN '2011-01-01' AND '2011-01-03'

first the earliest day and after that the latest date



(min<= expr AND expr<= max)

instead or use braces.


Use column name before using between condition

Like As:

Date BETWEEN '2011-01-01' AND '2011-01-03'

In your SQL You Forgot to put <strong>"Date"</strong> Field before <strong>BETWEEN</strong> Keyword


SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;



Notice COLUMN-NAME-HERE you need the date field


Hei you should have WHERE date_column BETWEEN '2011-01-03' AND '2011-01-01' put the exact name of your column instead of date_column so you'll have

SELECT * FROM `stats` WHERE `your_date_column` BETWEEN '2011-01-03' AND '2011-01-01' AND `email`='sarah@sarah.com' AND `city`='New York' AND `location`='New York' AND `date` GROUP BY action


Add the time to the date:

$qAddDate = " AND (dCreated >= '".$_POST['datefrom']."' AND dCreated <= '".$_POST['dateto'].":23:59:59')";


  • What is the point of MESI on Intel 64 and IA-32
  • How to merge two tables and transpose rows to columns
  • why isn't the natural height of a Frame updated immediately?
  • Extracting individual digits from a float
  • How to get links to open in the native browser in iOS Meteor apps?
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • D3 get axis values on zoom event
  • gspread or such: help me get cell coordinates (not value)
  • Groovy: Unexpected token “:”
  • Custom validator control occupying space even though display set to dynamic
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • JSON response opens as a file, but I can't access it with JavaScript
  • Replace value with Factor in r data.table
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • How to access EntityManager inside Entity class in EJB3
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Retrieving value from sql ExecuteScalar()
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • what is the difference between the asp.net mvc application and asp.net web application
  • Display Images one by one with next and previous functionality
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • SQL merge duplicate rows and join values that are different
  • KeystoneJS: Relationships in Admin UI not updating
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • apache spark aggregate function using min value
  • Checking variable from a different class in C#
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal