I have an events
table with a field called breaks
. This is populated with data in a comma separated format, i.e. 1,2,3
or 1
or 1,4,5
- the same format that MySQL's IN
command uses.
I'd then like to run a query - on the slots
table - to return all rows apart from those specified in events.breaks
.
The query, theoretically, should be something like this:
SELECT
`slots`.`id` AS id,
RIGHT(`slots`.`time`, 8) AS `time`
FROM
`slots`, `event`
WHERE
`slots`.`id` NOT IN (`event`.`breaks`)
But that doesn't appear to work - if event.breaks
is 4,5,7
, the only row from the slots
table that doesn't return is 4
!
SQLFiddle here: http://sqlfiddle.com/#!2/913fe/1/0