Comparison between mysql fields

1

I have a Mysql table where I store the years I get from a record, however I'm creating a search where the user selects from one date to another. In Mysql I did it this way:

SELECT * FROM tabela WHERE AnoEmpresa BETWEEN 1970 and 2014;

It does not return anything, even though it has data within those dates.

    
asked by anonymous 17.05.2015 / 21:44

1 answer

1

Your query looks correct.

The only thing I imagine is that you have the column AnoEmpresa in a non-numeric format. In this case MySQL will be looking for a string. (probably with the size between 1970 and 2014 characters). Try changing to a numeric type or date: TINYINT , YEAR or DATE ...

    
17.05.2015 / 22:08