• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

the between clause

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

My am getting an error for the following mysql syntax



Error:

right syntax to use near 'mydate BETWEEN 20091226 AND 20091226 GROUP BY item_name' at line 1

Thank you in advance
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I guess the problem is you missed an AND between the where clauses salesman and mydate.

select item_name,SUM(qty),SUM(total_amt) from invoice where salesman=? mydate BETWEEN ? AND ? GROUP BY item_name"



I guess the below code would work.. let me know..

select item_name,SUM(qty),SUM(total_amt) from invoice where salesman=? and mydate BETWEEN ? AND ? GROUP BY item_name
 
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For purposes of creating more-standard SQL queries I recommend you replace "X BETWEEN Y AND Z" syntax with "X > Y AND X < Z". At the very least it gives you better control over inclusive (<=,>=) searches as well as creates code that works better on more systems. Least of which, I find the syntax of both to be similar. Anyone have reasons for strongly recommend ever using the keyword BETWEEN?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Behaviour of BETWEEN is vendor specific.It might pick only the values in between the boundary values provided or includes both boundary values as well or .... BETWEEN
 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for those replies.

 
reply
    Bookmark Topic Watch Topic
  • New Topic