sennetta Posted January 14, 2008 Share Posted January 14, 2008 Trying to query the following table: CREATE TABLE `gigs` ( `id` int(6) NOT NULL auto_increment, `postdate` int(30) NOT NULL default '0', `gigdate` bigint(20) NOT NULL, `location` text NOT NULL, `price` varchar(20) NOT NULL, `deleted` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `postdate` (`postdate`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; with the following query: SELECT * FROM gigs WHERE deleted=0 AND id>-1 AND (id=(1 OR 1 OR 1 OR 6 OR 6 OR 6 OR 6 OR 6 OR 6 OR 2 OR 2)) ORDER BY gigdate and it's only returning the first result it finds when it should return three results: those with unique IDs 1,2, and 6. What's going on? Cheers, Anthony Link to comment https://forums.phpfreaks.com/topic/86000-solved-mysql-boolean-logic-ultra-newbie/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 14, 2008 Share Posted January 14, 2008 The distributive property does not work in programming. In mysql, use the IN() operator - http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in Link to comment https://forums.phpfreaks.com/topic/86000-solved-mysql-boolean-logic-ultra-newbie/#findComment-439186 Share on other sites More sharing options...
toplay Posted January 14, 2008 Share Posted January 14, 2008 ... WHERE `deleted` = 0 AND ID IN (1, 2, 6) Link to comment https://forums.phpfreaks.com/topic/86000-solved-mysql-boolean-logic-ultra-newbie/#findComment-439188 Share on other sites More sharing options...
sennetta Posted January 14, 2008 Author Share Posted January 14, 2008 Thank you very much for your help Link to comment https://forums.phpfreaks.com/topic/86000-solved-mysql-boolean-logic-ultra-newbie/#findComment-439196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.