<?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>isambard &#187; sql</title>
	<atom:link href="http://isambard.com.au/blog/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://isambard.com.au/blog</link>
	<description>musings on information design and architecture</description>
	<lastBuildDate>Sun, 13 May 2012 23:38:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>mysql concat does not like NULL values &#8211; use concat_ws instead</title>
		<link>http://isambard.com.au/blog/2010/09/24/mysql-concat-does-not-like-null-values-use-concat_ws-instead/</link>
		<comments>http://isambard.com.au/blog/2010/09/24/mysql-concat-does-not-like-null-values-use-concat_ws-instead/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 02:15:23 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Techniques]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://isambard.com.au/blog/?p=393</guid>
		<description><![CDATA[This just caused me several moments of pain. Here&#8217;s hoping I can remove that for you. I was needing to update a VARCHAR column by incrementally adding values read from another source. Simplest SQL (I thought) was: UPDATE table SET field = CONCAT(field, 'value ') WHERE id = ID; All ran fine. But pretty much [...]]]></description>
			<content:encoded><![CDATA[<p>This just caused me several moments of pain.  Here&#8217;s hoping I can remove that for you.</p>
<p>I was needing to update a VARCHAR column by incrementally adding values read from another source.  Simplest SQL (I thought) was:</p>
<p><code>UPDATE table SET field = CONCAT(field, 'value ') WHERE id = ID;</code></p>
<p>All ran fine.  But pretty much all of the fields came back NULL.  And to find out you have to actually read the details in the mysql manual.  A snip from the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat">official write-up on concat</a>:</p>
<p><em>CONCAT() returns NULL if any argument is NULL.</em></p>
<p>There&#8217;s the problem.  Most/all my starting values were NULL.  So concatenating actual values in the field did nothing as the NULL won.</p>
<p>The solution was very simple.  Replace the CONCAT() function with CONCAT_WS() where the &#8220;ws&#8221; bit means &#8220;with separator&#8221;.  Rather than just adding a space after the value in my example, specify the delimiter as the first parameter.  This makes the revised SQL command:</p>
<p><code>UPDATE table SET field = CONCAT_WS(' ', field, 'value ') WHERE id = ID;</code></p>
<p>It&#8217;s a lot more forgiven with NULLs; again snipped from the manual:</p>
<ul>
<li><em>If the separator is NULL, the result is NULL</em></li>
<li><em>CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument.</em></li>
</ul>
<p>Now it does not matter if there are any NULL values involved.  All just works.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fisambard.com.au%2Fblog%2F2010%2F09%2F24%2Fmysql-concat-does-not-like-null-values-use-concat_ws-instead%2F&amp;title=mysql%20concat%20does%20not%20like%20NULL%20values%20%E2%80%93%20use%20concat_ws%20instead" id="wpa2a_2"><img src="http://isambard.com.au/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://isambard.com.au/blog/2010/09/24/mysql-concat-does-not-like-null-values-use-concat_ws-instead/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting the iPhone simulator to recognise sqlite database changes done in Terminal</title>
		<link>http://isambard.com.au/blog/2010/06/14/getting-the-iphone-simulator-to-recognise-sqlite-database-changes-done-in-terminal/</link>
		<comments>http://isambard.com.au/blog/2010/06/14/getting-the-iphone-simulator-to-recognise-sqlite-database-changes-done-in-terminal/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 08:03:46 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Techniques]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://isambard.com.au/blog/?p=385</guid>
		<description><![CDATA[I&#8217;ve been tearing my hair out for an afternoon working with a simple DB application for the iPhone/iPad. Essentially it connects to a sqlite3 database as the source file. But each time I edited that database content in Terminal, nothing was changing in the application when run. Finally a solution. Need to reset the simulator [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been tearing my hair out for an afternoon working with a simple DB application for the iPhone/iPad.  Essentially it connects to a sqlite3 database as the source file.  But each time I edited that database content in Terminal, nothing was changing in the application when run.</p>
<p>Finally a solution.  Need to reset the simulator itself to remove the local copy taken/needed when running a DB application.</p>
<p>Option you need is <strong>Reset Contents and Settings&#8230;</strong>  under the iPhone Simulator menu.</p>
<p>Once reset when the application is run it pulls the updated database across as its copy.  Phew! </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fisambard.com.au%2Fblog%2F2010%2F06%2F14%2Fgetting-the-iphone-simulator-to-recognise-sqlite-database-changes-done-in-terminal%2F&amp;title=Getting%20the%20iPhone%20simulator%20to%20recognise%20sqlite%20database%20changes%20done%20in%20Terminal" id="wpa2a_4"><img src="http://isambard.com.au/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://isambard.com.au/blog/2010/06/14/getting-the-iphone-simulator-to-recognise-sqlite-database-changes-done-in-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparison and Logical Operators: Javascript, SQL, PHP and ASP Compared</title>
		<link>http://isambard.com.au/blog/2009/11/15/comparison-and-logical-operators-sql-php-and-asp-compared/</link>
		<comments>http://isambard.com.au/blog/2009/11/15/comparison-and-logical-operators-sql-php-and-asp-compared/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 11:32:54 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Techniques]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://isambard.com.au/blog/?p=669</guid>
		<description><![CDATA[Comparison and Logical operators are used for testing data values. Sadly the operators to use are not consistent across languages. This article summarises the most common operators for the key web development languages: Javascript ASP PHP SQL For SQL we checked both mySQL and MS SQL. All operators listed here should work in both. Comparison [...]]]></description>
			<content:encoded><![CDATA[<p>Comparison and Logical operators are used for testing data values. Sadly the operators to use are not consistent across languages. This article summarises the most common operators for the key web development languages:</p>
<ul>
<li>Javascript</li>
<li>ASP</li>
<li>PHP</li>
<li>SQL</li>
</ul>
<p>For SQL we checked both mySQL and MS SQL. All operators listed here should work in both.</p>
<h3>Comparison</h3>
<table cellspacing=0 cellpadding=6 width="100%" class="bordered">
<tr>
<th>Operator</th>
<th>Javascript</th>
<th>ASP</th>
<th>PHP</th>
<th>SQL</th>
</tr>
<tr>
<td>Less than</td>
<td><</td>
<td><</td>
<td><</td>
<td><</td>
</tr>
<tr>
<td>Less than or equal to</td>
<td><=</td>
<td><=</td>
<td><=</td>
<td><=</td>
</tr>
<tr>
<td>Greater than</td>
<td>></td>
<td>></td>
<td>></td>
<td>></td>
</tr>
<tr>
<td>Greater than or equal to</td>
<td>>=</td>
<td>>=</td>
<td>>=</td>
<td>>=</td>
</tr>
<tr>
<td>Equal to</td>
<td>==</td>
<td>=</td>
<td>== (equal)<br />=== (identical)</td>
<td>=</td>
</tr>
<tr>
<td>Not equal to</td>
<td>!=</td>
<td><></td>
<td>!= (not equal)<br /><> (not equal)<br />!== (not identical)</td>
<td><></td>
</tr>
</table>
<p>Testing for &#8220;identical&#8221; in PHP arrived with PHP 4. Two values are identical if they are the same, and the same type. Eg the values &#8220;1&#8243; (a string) and 1 (an integer) are equal but not identical.</p>
<h3>Logical</h3>
<table cellspacing=0 cellpadding=6 width="100%" class="bordered">
<tr>
<th>Operator</th>
<th>Javascript</th>
<th>ASP</th>
<th>PHP</th>
<th>SQL</th>
</tr>
<tr>
<td>AND</td>
<td>&#038;&#038;</td>
<td>AND</td>
<td>&#038;&#038;<br />AND</td>
<td>AND</td>
</tr>
<tr>
<td>OR</td>
<td>||</td>
<td>OR</td>
<td>||<br />OR</td>
<td>OR</td>
</tr>
<tr>
<td>NOT</td>
<td>!</td>
<td>NOT</td>
<td>!</td>
<td>NOT</td>
</tr>
</table>
<p>PHP provides two options for AND and OR with different operator precedences. Refer to the <A href="http://au2.php.net/manual/en/language.operators.php#language.operators.precedence">PHP manual: Operator Precedence</a> for details.</p>
<h3>useful reference lists</h3>
<dl>
<dt>Javascript</dt>
<dd><a href="http://www.w3schools.com/js/js_operators.asp">comparison and logical operators</a> (w3schools)</dd>
<dt>ASP</dt>
<dd><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasdj01/html/asp1200.asp">comparison and logical operators</a> (msdn)</dd>
<dt>PHP</dt>
<dd><a href="http://au2.php.net/manual/en/language.operators.comparison.php">comparison operators</a> (php.net)</dd>
<dd><a href="http://au2.php.net/manual/en/language.operators.logical.php">logical operators</a> (php.net)</dd>
<dt>MS SQL</dt>
<dd><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_3qpf.asp">comparison and logical operators</a> (msdn)</dd>
<dt>MySQL</dt>
<dd><a href="http://dev.mysql.com/doc/mysql/en/Comparison_Operators.html">comparison operators</a> (mysql.com)</dd>
<dd><a href="http://dev.mysql.com/doc/mysql/en/Logical_Operators.html">logical operators</a> (mysql.com) </dd>
</dl>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fisambard.com.au%2Fblog%2F2009%2F11%2F15%2Fcomparison-and-logical-operators-sql-php-and-asp-compared%2F&amp;title=Comparison%20and%20Logical%20Operators%3A%20Javascript%2C%20SQL%2C%20PHP%20and%20ASP%20Compared" id="wpa2a_6"><img src="http://isambard.com.au/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://isambard.com.au/blog/2009/11/15/comparison-and-logical-operators-sql-php-and-asp-compared/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logical and comparison operators for common web languages</title>
		<link>http://isambard.com.au/blog/2008/08/11/logical-and-comparison-operators-for-common-web-languages/</link>
		<comments>http://isambard.com.au/blog/2008/08/11/logical-and-comparison-operators-for-common-web-languages/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 05:42:22 +0000</pubDate>
		<dc:creator>steven</dc:creator>
				<category><![CDATA[Techniques]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://isambard.com.au/blog/?p=64</guid>
		<description><![CDATA[Comparison and Logical operators are used for testing data values. Sadly the operators to use are not consistent across languages. This article summarises the most common operators for the key web development languages: Javascript ASP PHP SQL For SQL we checked both mySQL and MS SQL. All operators listed here should work in both. Comparison [...]]]></description>
			<content:encoded><![CDATA[<p>
Comparison and Logical operators are used for testing data values.  Sadly the operators to use are not consistent across languages.  This article summarises the most common operators for the key web development languages:</p>
<ul>
<li>Javascript</li>
<li>ASP</li>
<li>PHP</li>
<li>SQL</li>
</ul>
<p>
For SQL we checked both mySQL and MS SQL.  All operators listed here should work in both.</p>
<h2>Comparison</h2>
<table class='boxed' width='100%'>
<tr>
<th>Operator</th>
<th>Javascript</th>
<th>ASP</th>
<th>PHP</th>
<th>SQL</th>
</tr>
<tr>
<td>Less than</td>
<td>&lt;</td>
<td>&lt;</td>
<td>&lt;</td>
<td>&lt;</td>
</tr>
<tr>
<td>Less than or equal to</td>
<td>&lt;=</td>
<td>&lt;=</td>
<td>&lt;=</td>
<td>&lt;=</td>
</tr>
<tr>
<td>Greater than</td>
<td>&gt;</td>
<td>&gt;</td>
<td>&gt;</td>
<td>&gt;</td>
</tr>
<tr>
<td>Greater than or equal to</td>
<td>&gt;=</td>
<td>&gt;=</td>
<td>&gt;=</td>
<td>&gt;=</td>
</tr>
<tr>
<td>Equal to</td>
<td>==</td>
<td>=</td>
<td>== (equal)<br />=== (identical)</td>
<td>=</td>
</tr>
<tr>
<td>Not equal to</td>
<td>!=</td>
<td><></td>
<td>!= (not equal)<br /><> (not equal)<br />!== (not identical)</td>
<td><></td>
</tr>
</table>
<p>
Testing for &#8220;identical&#8221; in PHP arrived with PHP 4.  Two values are identical if they are the same, and the same type. Eg the values &#8220;1&#8243; (a string) and 1 (an integer) are equal but not identical.</p>
<h2>Logical</h2>
<table class='boxed' width='100%'>
<tr>
<th>Operator</th>
<th>Javascript</th>
<th>ASP</th>
<th>PHP</th>
<th>SQL</th>
</tr>
<tr>
<td>AND</td>
<td>&#038;&#038;</td>
<td>AND</td>
<td>&#038;&#038;<br />AND</td>
<td>AND</td>
</tr>
<tr>
<td>OR</td>
<td>||</td>
<td>OR</td>
<td>||<br />OR</td>
<td>OR</td>
</tr>
<tr>
<td>NOT</td>
<td>!</td>
<td>NOT</td>
<td>!</td>
<td>NOT</td>
</tr>
</table>
<p>
PHP provides two options for AND and OR with different operator precedences.  Refer to the <a href="http://au2.php.net/manual/en/language.operators.php#language.operators.precedence">PHP manual: Operator Precedence</a> for details.</p>
<h2>useful reference lists</h2>
<dl>
<dt>Javascript</dt>
<dd><a href="http://www.w3schools.com/js/js_operators.asp">comparison and logical operators</a> (w3schools)
        </dd>
<dt>ASP</dt>
<dd><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasdj01/html/asp1200.asp">comparison and logical operators</a> (msdn)
        </dd>
<dt>PHP</dt>
<dd><a href="http://au2.php.net/manual/en/language.operators.comparison.php">comparison operators</a> (php.net)</dd>
<dd><a href="http://au2.php.net/manual/en/language.operators.logical.php">logical operators</a> (php.net)</dd>
<dt>MS SQL</dt>
<dd><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_3qpf.asp">comparison and logical operators</a> (msdn)
        </dd>
<dt>MySQL</dt>
<dd><a href="http://dev.mysql.com/doc/mysql/en/Comparison_Operators.html">comparison operators</a> (mysql.com)</dd>
<dd><a href="http://dev.mysql.com/doc/mysql/en/Logical_Operators.html">logical operators</a> (mysql.com)</dd>
</dl>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fisambard.com.au%2Fblog%2F2008%2F08%2F11%2Flogical-and-comparison-operators-for-common-web-languages%2F&amp;title=Logical%20and%20comparison%20operators%20for%20common%20web%20languages" id="wpa2a_8"><img src="http://isambard.com.au/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://isambard.com.au/blog/2008/08/11/logical-and-comparison-operators-for-common-web-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

