How to consult between months or dates

0

I am trying to make a query to my table by specifying, taking an id, in specific:

  $id=$_GET['id'];
        $Consult= "SELECT * FROM pagos_colegio WHERE id='$id' AND mes BETWEEN ('jan' AND 'Dec');
 ";
    $result= $conexion->query($Consult);
    if($fila = $result->fetch_assoc())
    {


    }

The idea is to know where this id appears between those months, Thanks in advance.

    
asked by Alexander Quiroz 02.07.2016 в 14:35
source

2 answers

1

What I understand to your question would be this

SELECT * FROM pagos_colegio WHERE id='$id' AND mes BETWEEN (DATE('2015-12-00') AND DATE('2015-12-00')+ INTERVAL 1 MONTH) ;

This query will send you between the 1 month interval

    
answered by 02.07.2016 / 19:01
source
0

If you want to consult dates you would have to add a DATE field to your table and do: month BETWEEN date1 AND date2 Or if you only want to check if you are between certain months you could list them and place: month BETWEEN 1 AND 12.

    
answered by 02.07.2016 в 15:30