SQLite multiple conditions in WHERE LIKE
<p>Is there anyway to have multiple conditions in a WHERE x LIKE %x% statement without using OR?</p>

<p>Basically I want to be able to select something where column1 LIKE %something% AND column2 LIKE %check1% OR %check2% OR %check3%</p>

<p>However, using OR removes my first previous check for column1 but I need this to stay in place</p>

<p>Here is what I'm currently using.. but I'm wondering if there is a better way of doing this so I don't have to keep repeating column1</p>

<pre><code>SELECT id FROM test WHERE 
column1 LIKE '%bob%' AND column2 LIKE '%something%' 
OR column1 LIKE '%bob%' AND column2 LIKE '%somethingdifferent%' 
OR column1 LIKE '%bob%' AND column2 LIKE '%somethingdifferent2%'
</code></pre>

<p>Basically.. right now I keep having to repeat</p>

<pre><code>column1 LIKE %bob%' AND .........
</code></pre>

<p>Just wondering if there is a better way to achieve this?</p>

<p>What about:</p>

<pre><code>SELECT id FROM test WHERE 
column1 LIKE '%bob%' AND
    (column2 LIKE '%something%' OR
     column2 LIKE '%somethingdifferent%' OR
     column2 LIKE '%somethingdifferent2%')
</code></pre>

<p>It's logically equivalent...</p>

<p>You can also use a RegEx: see <a href="http://stackoverflow.com/questions/5071601/how-do-i-use-regex-in-a-sqlite-query">How do I use regex in a SQLite query?</a></p>

python database sqlite