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 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
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 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 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
How To Use Database Driver
.style1 { text-align: center; } How To Use Database Driver Database... and connection between database and driver. It maintains a list of driver...; Class.forName("com.mysql.jdbc.Driver"); //MySql Driver   
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
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 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
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript  when click on the next..._name where id=..; database:mysql technology:jsp,servlet,javascript,jstl  
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
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 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
MySQL Arithmetic
MySQL Arithmetic This example illustrates how to use arithmetic operator in the MySQL. In this example we use arithmetic operator (+, /, -, *, %).   Query   Output  
MySQL Attribute
MySQL Attribute This example illustrates how to use the COLLATE attribute in MySQL. In this example we use the COLLATE attribute to define the attribute of the table. In the query below character data types (CHAR, VARCHAR, TEXT) can
How to use Servlet and Ajax?
How to use Servlet and Ajax?  How to use Servlet and Ajax
MySQL Count
MySQL Count       This example illustrates how to use count() in MySQL database. Count(): The Count.... It returns a numeric value. If you use COUNT(*) that counts the number of rows.  
How to use AT Commands with J2ME?
How to use AT Commands with J2ME?  How to use AT Commands with J2ME? Thank you for your answer
how to use calender in php
how to use calender in php  how to put calender in php
how to use mouse pressed
how to use mouse pressed   to action mouse clicked
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 use button in array
how to use button in array  plz tell me how to code for button in array
how to use JOptionPane.YES_NO_OPTION
how to use JOptionPane.YES_NO_OPTION  As i said earliar i am making... logging out finally.. i also thinking how to use the input (yes or no ) given... dialog should appear which ask for yes or no . PROBLEM is i dont know how
how to use an editable combobox
how to use an editable combobox   Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
how to use setAttribute
how to use setAttribute  how to get following codes using setAttributes in java??? Employee xlink:type="extended" xlink:show="new" xlink:actuate="onRequest
How to use dojoscript with jsf?
How to use dojoscript with jsf?  Hi all , am new to jsf. can anyone help me out in using dojo script frame work with jsf. how to integrate dojo into jsf. Thanks in advance

Ads