If value is zero don't check in where statement?

2018-03-22 mysql

I want to check if a value matches another, but only if that value is not zero. The first two examples would be considered in the where statement, but not the third. I was trying to see if an if statement would work, but I don't know where to begin.

Example of a match:
column1 = 'theredroof'
column2 = 'theredroof'

Example of non match:
column1 = 'theredroof'
column2 = 'thegreenroof'

Example of exclusion:
(I don't want it to consider this in the where statement at all)
column1 = 'theredroof'
column2 = 0
column1 = 0
column2 = 0

Here is an example of the mysql query:

SELECT `books`.* FROM `books` 
LEFT JOIN issues ON issues.id = books.issue_id 
LEFT JOIN titles ON titles.id = issues.title_id
LEFT JOIN lists ON books.id = lists.book_id 
WHERE ( lists.customer_id = '900001' 
AND lists.volume = issues.volume AND `books`.`status_id` = '3' 
AND `books`.`deleted` = "0" ) 
GROUP BY `books`.`id`

So if lists.volume = 0 I don't want it to be checked in the where statement.


select column1, column2, if (column1 = column2, 'match', 'not matched') matched
from x
where column1 <> 0 and column2 <> 0