1

I'm new to MySQL. Can anyone help me with this.

I got two dates say From_Date = '2012-04-01', To_Date = '2012-04-17'. I want to get all the details from the table that contains the date within the given date.

Name      Subject  Start_Date  End_Date
Madhu     Science  2011-05-01  2012-05-01
Madhu     Biology  2012-04-01  2012-04-07
Mahesh    Science  2011-05-01  2012-05-01
Jagadesh  Biology  2011-05-01  2012-03-01

My answer should contain:

Madhu   Science
Madhu   Biology
Mahesh  Science

2 Answers 2

2
select * from table_name 
         where start_date >= "2012-04-01" 
               and end_date <= "2012-04-17"
Sign up to request clarification or add additional context in comments.

2 Comments

suppose if i hava a data say Madhu Maths '2012-03-03' '2012-04-5' I want to get this data also in my output
@jones: Could you explain all the criteria to retrieve result in question itself sorry i did not understand what are you talking about now?
1

You can also use BETWEEN statement part.

See mySQL Reference # Between

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.