MySQL: consult a date in the varchar field

0

I'm trying to find a date within a MySQL field that contains several dates separated by commas. Example:

tabla_agenda: id (integer) fechas (text o varchar)

Example of the table:

registro: 1 / 2017-04-04,2017-04-06,2017-04-08
registro: 2 / 2017-04-08,2017-05-08,2017-06-08

The query I want to make is s elect * from tabla_agenda where '2017-04-08' in (fechas)

But it does not give me any results. If I leave only one date, he finds it well, he does not take into account the separation of the commas as a whole. I have tried single quotes, double quotes in both criteria and records

Any ideas?

    
asked by Gerardo Gorelik Zonis 04.04.2017 в 00:11
source

1 answer

0

Your query is missing the field where you have your date as I would be like this

select * from tabla_agenda where campo_fecha in (fechas)

Where dates would be a variable that contains the dates:

'2017-03-04',´´2017-04-01´...

And field_date your change of table tabla_agenda

    
answered by 04.04.2017 в 01:08