Question

enter image description here

Architecture of my table is as following:

enter image description here

I have the above table, wherein date datatype filed "l_from", i want to select all those records which having today date or all the future date from now.

For this i have used the following queries:

SELECT emp_sno,emp_type,l_from,l_to,l_nature 
FROM leaves_history 
WHERE l_from < CURDATE() AND emp_type = 1

But the above query does not help.
I have changed the

where l_from >= curdate()

where l_from <= curdate() 

but in no clause return the highlighted row.

What should i have to change in?

thanks in advance

Was it helpful?

Solution

Give this a go?

SELECT emp_sno,emp_type, l_from, l_to, l_nature 
FROM leaves_history 
WHERE l_from <= NOW() AND emp_type = 1

EDIT Changed <= to >=

SELECT emp_sno,emp_type, l_from, l_to, l_nature 
FROM leaves_history 
WHERE l_from >= DATE(NOW()) AND emp_type = 1

OTHER TIPS

Maybe your problem is not the query? But anyway this would work:

SELECT
  emp_sno,
  emp_type,
  l_from,
  l_to,
  l_nature
FROM leaves_history
WHERE l_from >= CURDATE()
    AND emp_type = 1
ORDER BY l_from

try something like this :

SELECT emp_sno,emp_type,l_from,l_to,l_nature
FROM leaves_history
WHERE l_from >= '2014-05-05'
AND emp_type = 1

where 2014-05-05 is current date

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top