<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Optimus Pete &#187; sql</title>
	<atom:link href="http://tech.petegraham.co.uk/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.petegraham.co.uk</link>
	<description>yes i love technology</description>
	<lastBuildDate>Fri, 16 Jul 2010 16:30:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL: Selecting Specifying Multiple Field Values</title>
		<link>http://tech.petegraham.co.uk/2007/03/22/sql-selecting-specifying-multiple-field-values/</link>
		<comments>http://tech.petegraham.co.uk/2007/03/22/sql-selecting-specifying-multiple-field-values/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 18:05:06 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/03/22/sql-selecting-specifying-multiple-field-values/</guid>
		<description><![CDATA[Here are 3 different ways to perform a DB select when you want to specify two or more values for a field.
1. Use th OR operator
PLAIN TEXT
SQL:




SELECT * FROM people


WHERE &#40;first_name = 'pete'


OR first_name = 'paul'&#41;; 






2. Use a Regular Expression
PLAIN TEXT
SQL:




SELECT * FROM people


WHERE first_name ~'^pete&#124;paul$'; 






3. Use an array
PLAIN TEXT
SQL:




SELECT * FROM people


WHERE [...]]]></description>
			<content:encoded><![CDATA[<p>Here are 3 different ways to perform a DB select when you want to specify two or more values for a field.</p>
<p>1. Use th OR operator</p>
<div class="igBar"><span id="lsql-4"><a href="#" onclick="javascript:showPlainTxt('sql-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-4">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> people</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color:#006600; font-weight:bold;">&#40;</span>first_name = <span style="color: #ff0000;">'pete'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">OR</span> first_name = <span style="color: #ff0000;">'paul'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
2. Use a Regular Expression</p>
<div class="igBar"><span id="lsql-5"><a href="#" onclick="javascript:showPlainTxt('sql-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-5">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> people</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> first_name ~<span style="color: #ff0000;">'^pete|paul$'</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
3. Use an array</p>
<div class="igBar"><span id="lsql-6"><a href="#" onclick="javascript:showPlainTxt('sql-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-6">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> people</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span> first_name = ANY<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'{pete,paul}'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Note: These should all work in PostgreSQL, I suspect the SQL may need altering for 2 and 3 to work with MySQL.</p>
<p># Pete Graham</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/03/22/sql-selecting-specifying-multiple-field-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
