There was one problem and I can not find a solution.
I have table something like this
CREATE TABLE IF NOT EXISTS `system_tests_run` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`test_id` int(11) NOT NULL,
`questions_id` text NOT NULL,
`run_id` int(11) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`date_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`date_from` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`class` varchar(64) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
`minutes` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `system_tests_run` (`id`, `test_id`, `questions_id`, `run_id`, `created`, `date_to`, `date_from`, `class`, `minutes`) VALUES
(1, 1, '1', 1, '2014-03-02 16:59:07', '2014-03-02 17:05:00', '2014-03-02 16:58:00', '1,2,3,4,5,6,7,8,9', 15);
and i using this query for load data joined with table users,
SELECT r.date_from,
r.date_to,
r.id,
t.name,
t.subject,
u.meno,
u.priezvisko
FROM `system_tests_run` r
LEFT JOIN system_tests t
ON t.id = r.test_id
LEFT JOIN system_users u
ON u.id = r.run_id
WHERE r.class IN (1)
AND r.date_from <= NOW()
AND r.date_to >= NOW();
This table is for online exam testing, and in field class i store name of class for example (2) , my query working only for 1st class, if had for example in where clause WHERE r.class IN (2) so the command will not work
Query works fine if i use WHERE r.class IN (1,2,3,4,5,6,7,8,9) but i need only one, Because the student has only one class and for the class may be directed test, not all You can not think of any solution suitable for me? Thanks,.