title: Mysql - selecting distinct if not null
body: <p>I need to give my client the option to publish some posts with same name in different categories. the CMS is closed and I can't add anymore fields... 
  There is a spare field which I can use to identify posts as identical, but I don't won't a situation where to exact posts will load (posts in my case are images).</p>
  
  <p>So I figured my client can specify identical "field" for all identical posts.</p>
  
  <p>The problem is that the default for the field is null. if i'll use distinct, only one result will come from all the non-identical posts (all of them by default = null)...</p>
  
  <p>Is there a way to select distinct "field" if not null?</p>
  
  <p>I tried looking and trial and error with the above but it didn't work for me...</p>
  
  <p>The query itself is quite simple...</p>
  
  <pre><code>SELECT id,introtext,publish_up,publish_down 
  from #__content 
  WHERE catid IN(936,937,940,959,972,988,991) AND state = 1 
    AND ( publish_up = "0000-00-00 00:00:00" OR publish_up &lt;= "2011-10-30 12:12:59" )
    AND ( publish_down = "0000-00-00 00:00:00" OR publish_down &gt;= "2011-10-30 12:12:59" ) 
  
  --removed duplicated query
  </code></pre>
  
  <p>Will appreciate any clue or directions... 
  Thanks!
  Yanipan</p>