Search code examples
mysqlfind-in-set

MYSQl - Check if group of dates are in a comma separated list of dates


My table design:

enter image description here

How to get the records If dates '04-11-2016' OR '11-11-2016' available in week_days column.

Note: The dates are not same, It's have one or more dates.

Actual Query:

SELECT * FROM `sh_products` WHERE FIND_IN_SET('04-11-2016','11-11-2016',week_days);

Expecting Result:

enter image description here


Solution

  • Just OR together two calls to FIND_IN_SET:

    SELECT *
    FROM sh_products
    WHERE FIND_IN_SET('04-11-2016', week_days) > 0 OR
          FIND_IN_SET('11-11-2016', week_days) > 0