title: MySQL mixing AND's and OR's, parenthesis not helping
body: <p>For some reason this query does not produce the correct results, can anyone see if I am making a simple mistake. If worst comes to worse I will seperate it into two querys and use my app engine to merge the results, but that is slow and dirty and I would love to keep this is one query.</p>
  
  <pre><code>SELECT *
  FROM `chat_messages` 
  WHERE
  (
  (`from` = :me AND `to` = :them AND `from_clear` = FALSE) OR 
  (`from` = :them AND `to` = :me AND `to_clear` = FALSE)
  ) 
  ORDER BY `time` ASC;
  </code></pre>
  
  <p>This is my table:</p>
  
  <pre><code>CREATE TABLE `chat_messages` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `from` varchar(16) NOT NULL,
    `to` varchar(16) NOT NULL,
    `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `message` text NOT NULL,
    `read` tinyint(1) NOT NULL DEFAULT '0',
    `from_clear` tinyint(1) NOT NULL DEFAULT '0',
    `to_clear` tinyint(1) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`),
    KEY `from` (`from`),
    KEY `to` (`to`),
    KEY `time` (`time`),
    KEY `read` (`read`),
    KEY `from_clear` (`from_clear`),
    KEY `to_clear` (`to_clear`)
  ) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>Any help would be much appreciated.</p>