1

How can I compare different rows of different columns in the same table in MySQL?? I want to get all the data between given Start_Date and End_Date in my database table. But two dates are not in the same row.Ex,

Start_Date    End_Date      Data
2011-07-01    2011-07-31     AA
2011-08-01    2011-08-31     BB

I want to get data between '2011-07-01' and '2011-08-31'.How can I do that? Please reply me with MySQL code.Thanks a lot.

0

2 Answers 2

1

try

where 
Start_Date between  '2011-07-01' and '2011-08-31' 
OR
End_Date between  '2011-07-01' and '2011-08-31'
Sign up to request clarification or add additional context in comments.

Comments

0

Are You Want the data between '2011-07-01' and '2011-08-31'. Thats Start_Date is 2011-07-01 or more and End_Date is '2011-08-31' or less.

Am I Correct?. If i correct Try below Query.

SELECT Data FROM table_Name WHERE Start_Date <= '2011-07-01' AND End_Date >= '2011-08-31'

Happy Coding.

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.