<?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; database</title>
	<atom:link href="http://tech.petegraham.co.uk/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.petegraham.co.uk</link>
	<description>yes i love technology</description>
	<lastBuildDate>Wed, 25 Aug 2010 10:06:53 +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>
		<item>
		<title>MySQL tips: Grants and Changing Passwords</title>
		<link>http://tech.petegraham.co.uk/2007/02/23/mysql-tips-grants-and-changing-passwords/</link>
		<comments>http://tech.petegraham.co.uk/2007/02/23/mysql-tips-grants-and-changing-passwords/#comments</comments>
		<pubDate>Fri, 23 Feb 2007 15:21:39 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[changing passwords]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[grants]]></category>

		<guid isPermaLink="false">http://tech.petegraham.co.uk/2007/02/23/mysql-tips-grants-and-changing-passwords/</guid>
		<description><![CDATA[I was doing some work administering MySQL databases earlier in the week. I haven’t done much with MySQL in over half a year since we use Postgres as the backend for phuser.com, needless to say I’d forgotten a lot of the commands! Here are a few MySQL tips which I’m putting up here for my [...]]]></description>
			<content:encoded><![CDATA[<p>I was doing some work administering MySQL databases earlier in the week. I haven’t done much with MySQL in over half a year since we use Postgres as the backend for phuser.com, needless to say I’d forgotten a lot of the commands! Here are a few MySQL tips which I’m putting up here for my own reference but if anyone else finds them useful then that’s great!</p>
<p>First thing I had to do was create a database, for this example we’ll call the DB stats.</p>
<p><strong>CREATE DATABASE STATS</strong></p>
<p>Normally you will want to create a new user to access your DB, here’s how to do this:</p>
<p><strong>GRANT All PRIVILEGES ON stats.* TO 'statsBoy'@'localhost' IDENTIFIED BY 'rubbishPassword';</strong></p>
<p>Here I have created a new user called "statsBoy" with password "rubbishPassword". I'm giving statsBoy all privileges to the DB and I’m only letting statsBoy connect from localhost so he can only to connect from the server the DB is on. Don’t forget to put the .* on the end of your DB otherwise you won’t be able to access your DB tables (this has screwed me over before!).</p>
<p>After doing any granting you’ve got to flush your privileges for them to take effect:</p>
<p><strong>FLUSH PRIVILEGES;</strong></p>
<p>Doing this will tell you “Query OK, 0 rows affected” it lies! Rows have been affected and your privileges should work now. I normally log on using the mySQL commandline interface and check.</p>
<p>Now my earlier password wasn’t very good, to change it do this:</p>
<p><strong>SET PASSWORD FOR 'statsBoy'@'localhost' = PASSWORD('Rd1x3$k8');</strong></p>
<p>No flushing of privileges is required here. Well that’s all for today MySQL maniacs, I'm sure they'll be more commandline Database Administration fun soon!</p>
<p>// Pete Graham</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.petegraham.co.uk/2007/02/23/mysql-tips-grants-and-changing-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
