How to use between in mysql.

Ads
 

How to use between in mysql.

I want to display records inbetween two dates and also want to use where condition( like and deptname='Pediatry Department').

View Answers

April 3, 2012 at 1:42 PM

Syntax:

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

Here is an example, we have a table named data(id, name, dob,deptName.....) and we have to find the data of a person whose names starts with r and deptname is software and dob lies between two specified dates.

Here is the query for this:

select * from data where dob between '2005-12-01'and '2005-12-31' and name LIKE 'r%' and deptName='software';

Ads









Related Tutorials/Questions & Answers:
How to use between in mysql.
How to use between in mysql.  I want to display records inbetween two dates and also want to use where condition( like and deptname='Pediatry... WHERE column_name BETWEEN value1 AND value2 Here is an example, we have a table
HOW CN I USE WHERE AND BETWEEN CLAUSE SIMULTANEOUSLY... IN MYSQL
HOW CN I USE WHERE AND BETWEEN CLAUSE SIMULTANEOUSLY... IN MYSQL  sir, how can i use WHERE and BETWEEN clause simultaneously..? my tables details... between two dates whose expfor_id = 1 my query is SELECT * FROM expenditures
Advertisements
How to select Data Between Two dates in Java, MySQL
How to select Data Between Two dates in Java, MySQL  How to select Data Between Two dates in Java, MySQL? Thanks in advance.   http://www.v7n.com/forums/coding-forum/294668-how-select-data-between-two-dates-php
mysql between dates not between dates
mysql between dates not between dates  I am trying to list the data between dates and not between dates using join method ..but that not working for me
Upgrading databases between MySQL 5.0 to MySQL 5.5
Upgrading databases between MySQL 5.0 to MySQL 5.5  Upgrading databases between MySQL 5.0 to MySQL 5.5
mysql difference between two numbers
mysql difference between two numbers  How to get total bate difference between two dates for example 1/01/2012 and 1/02/2012 in MYSQL?   ..., '01/02/2012', 103))   DATEDIFF() in MYSQL always returns the difference
PHP and MySQL BETWEEN dates with different years
PHP and MySQL BETWEEN dates with different years  I have a database... they should only show on the site when the date chosen falls between those dates. I thought it made sense to make use of the SQL BETWEEN statement, but it does
Mysql Date in between
Mysql Date in between       The Tutorial illustrates an example Mysql date in between . In this Tutorial we illustrate an example that help you to get the date in between. Query
How to use select Statement in MySQL?
How to use select Statement in MySQL?  Hi, How to use select Statement in MySQL? I want to learn the various ways to use the SQL select statement. Thanks   Hi, What is the use of MySQL select clause? MySQL select
Difference between not null and primary key in mysql
Difference between not null and primary key in mysql  Explain not null and primary key in mysql
How to download install and use MySQL workbench?
How to download install and use MySQL workbench?  Hi, What are the steps of download and install MySQL workbench on Windows computer? Thanks   Hi, You can download the MySQL workbench from mysql.com and then install
how to use mysql event scheduler in hibernate
how to use mysql event scheduler in hibernate  Hi all, I am creating... of time, i need to use mysql event scheduler My query is like this create event... use this query in function session.createQuery("); it gives exception
How to get factorial in mysql
How to get factorial in mysql  Hi, In order to improve the speed of my queries, one in particular tries to find matches between multiple tables, I am trying to use prime numbers to speed the process, but I have been googling
How to connect to MySQL in JSP?
How to connect to MySQL in JSP?  How to connect to MySQL in JSP..., You can use the Java JDBC code to connect to MySQL database in JSP page. Check the tutorial: Connect JSP with mysql Thanks
What is the difference between MongoDB and MySql?
The difference between MongoDB and MySql is that the in former one whole... than MySql will work perfectly but if a data is complex and you want to store serialized arrays or JSON objects then MongoDB is advised. MySql has JOIN
How alter table in MySQL?
How alter table in MySQL?  Hi, I have a table and I want to alter an int field into text field. How to alter the table in MySQL? Thanks   Hi, You can use the following query: alter table employees change empid empid
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
How to list even numbers between 1 and 100?
How to list even numbers between 1 and 100?  Hi, I Java to check if a number is even? How to list even numbers between 1 and 100? Thanks  ... a variable i then you can use following code for finding if the number is even
MySQL How to Topic
/manual_toc.html#Compatibility    How does MySQL use... MySQL How to Topic       How to installation mysql window 2000 and window XP http
How to start learning MySQL?
How to start learning MySQL?  Hello developers, I am total beginner... and want to learn MySQL. How to start learning MySQL? Which are good tutorials... at How to download and install MySQL on Windows 10? You can learn SQL from
how to get string between two characters
how to get string between two characters  hgow to get string from between two characters. ex:[email protected] from the above word i want a string between characters . and @ send the required method and give better example
How to manage cookie in between two JSP Pages
How to manage cookie in between two JSP Pages  How to manage cookie in between two JSP Pages   you can set cookies in response object e.g.response.addCookie(new Cookie("userName","Password")). Chandraprakash Sarathe
How to download MySQL JDBC driver?
How to download MySQL JDBC driver?  Hi, What is JDBC Driver? How to download MySQL JDBC driver? Thanks   Hi, JDBC - Java database... to download and use MySQL JDBC Driver: MySQL JDBC driver can be downloaded from https
how can i draw line between two panel contaning circle and line between their center?
how can i draw line between two panel contaning circle and line between their center?   how can i draw line between two panel contaning circle and line between their center
How to delete data from MySQL?
How to delete data from MySQL?  Hi, How I can conditionally delete the data from MySQL Table? Thanks   Hi, You can use the where clause to conditionally delete the data from MySQL database table. Here is some query
How do I upgrade mysql?
How do I upgrade mysql?  How do I upgrade mysql
SQL Date Between
SQL Date Between       Mysql Date Between return the date between the two existing date. Understand with Example The Tutorial illustrate an example from 'Date Between
how to migrate java db to mysql
how to migrate java db to mysql  I have an aplication,for migrating java db to mysql db.how it will done
how insert multiple images in mysql database with use of struts 1.3.8 or java method, with single bean,or using array
how insert multiple images in mysql database with use of struts 1.3.8 or java method, with single bean,or using array  i am using netbeans 7.0 ,with struts 1.3.8 and i want to insert multiple images in mysql database ,with use
how to create directed line between two buttons when i clicked there
how to create directed line between two buttons when i clicked there  Hi I have to create a topology between 6 nodes. 6 nodes are created as 6... line should be formed between them.Give me a solution
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.  Initially,display 7or10 records on a jsp pageand when click on the NEXT button(or href link) then display next 7 records

Ads