Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Sqldate MySQL By Date

Related Tutorials


 
 

Share on Google+Share on Google+

MySQL By Date

Advertisement
In this section, you will learn about how to fetch the data in order by date in MySQL.

MySQL By Date

     

In this section, you will learn about how to fetch the data in order by date in MySQL. We can arrange the data through the ORDER BY clause. In the following example, we will create a table and view all data then we will use the ORDER BY clause.

Table: employee

CREATE TABLE `employee` ( 
`emp_id` int(11) NOT NULL auto_increment, 
`emp_name` varchar(10) character set utf8 default NULL, 
`emp_salary` int(11) default NULL, 
`emp_startDate` datetime default NULL, 
PRIMARY KEY (`emp_id`) 
)

Select all data in "employee" table with the following query.

Query:

SELECT * FROM employee;

Select all the data but in date order using ORDER BY clause by executing the the following query.

Query:  

SELECT * FROM employee ORDER BY emp_startDate;

Output:

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 20, 2009

Related Tutorials

Discuss: MySQL By Date   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Chiranjit Mondal
August 23, 2012
oracle

emp_startDate` datetime default NULL, it is wrong;what is datatype of date field;
DMCA.com