<?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>Pario TechnoBlob &#187; MySQL</title>
	<atom:link href="http://pario.no/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Wed, 14 Jul 2010 12:12:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Howto backup mysql stored functions and stored procedures</title>
		<link>http://pario.no/2009/11/02/howto-backup-mysql-stored-functions-and-stored-procedures/</link>
		<comments>http://pario.no/2009/11/02/howto-backup-mysql-stored-functions-and-stored-procedures/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 21:28:10 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[stored functions]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1257</guid>
		<description><![CDATA[This is how you can backup you MySQL database(s) and stored procedures # mysqldump --routines &#60;dbname&#62; Or you can backup only the stored procedures # mysqldump --no-create-db --no-create-info --no-data --routines &#60;dbname&#62; var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDkvMTEvMDIvaG93dG8tYmFja3VwLW15c3FsLXN0b3JlZC1mdW5jdGlvbnMtYW5kLXN0b3JlZC1wcm9jZWR1cmVzLzx3cHRiPkhvd3RvIGJhY2t1cCBteXNxbCBzdG9yZWQgZnVuY3Rpb25zIGFuZCBzdG9yZWQgcHJvY2VkdXJlczx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";]]></description>
			<content:encoded><![CDATA[<p>This is how you can backup you MySQL database(s) and stored procedures</p>
<pre>
# mysqldump --routines &lt;dbname&gt;</pre>
<p>Or you can backup only the stored procedures</p>
<pre>
# mysqldump --no-create-db --no-create-info --no-data --routines &lt;dbname&gt;</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDkvMTEvMDIvaG93dG8tYmFja3VwLW15c3FsLXN0b3JlZC1mdW5jdGlvbnMtYW5kLXN0b3JlZC1wcm9jZWR1cmVzLzx3cHRiPkhvd3RvIGJhY2t1cCBteXNxbCBzdG9yZWQgZnVuY3Rpb25zIGFuZCBzdG9yZWQgcHJvY2VkdXJlczx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2009/11/02/howto-backup-mysql-stored-functions-and-stored-procedures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql alternative to PHP substr_count function</title>
		<link>http://pario.no/2009/10/23/mysql-alternative-to-php-substr_count-function/</link>
		<comments>http://pario.no/2009/10/23/mysql-alternative-to-php-substr_count-function/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 15:05:37 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[stored functions]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1231</guid>
		<description><![CDATA[The substr_count function in PHP counts the number of substring occurrences. This post describes how to create a mysql stored function to behave just like PHP&#8217;s substr_count function. This function can be created from your mysql console delimiter &#124;&#124; DROP FUNCTION IF EXISTS substrCount&#124;&#124; CREATE FUNCTION substrCount(s VARCHAR(255), ss VARCHAR(255)) RETURNS TINYINT(3) UNSIGNED LANGUAGE SQL [...]]]></description>
			<content:encoded><![CDATA[<p>The substr_count function in PHP counts the number of substring occurrences. This post describes how to create a mysql stored function to behave just like PHP&#8217;s <a href="http://www.php.net/manual/en/function.substr-count.php">substr_count</a> function.</p>
<p>This function can be created from your mysql console </p>
<pre>
delimiter ||
DROP FUNCTION IF EXISTS substrCount||
CREATE FUNCTION substrCount(s VARCHAR(255), ss VARCHAR(255)) RETURNS TINYINT(3) UNSIGNED LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA
BEGIN
DECLARE count TINYINT(3) UNSIGNED;
DECLARE offset TINYINT(3) UNSIGNED;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s = NULL;

SET count = 0;
SET offset = 1;

REPEAT
IF NOT ISNULL(s) AND offset > 0 THEN
SET offset = LOCATE(ss, s, offset);
IF offset > 0 THEN
SET count = count + 1;
SET offset = offset + 1;
END IF;
END IF;
UNTIL ISNULL(s) OR offset = 0 END REPEAT;

RETURN count;
END;

||

delimiter ;
</pre>
<p><strong>Usage</strong></p>
<p><strong>Example 1</strong></p>
<pre>
SELECT substrCount('/this/is/a/path', '/') `count`;</pre>
<p>`count` would return 4 in this case. Can be used in such cases where you might want to find the &#8220;depth&#8221; of a path, or for many other uses.<br />
This function is great to count the content of mysql ENUM and SET field data types.</p>
<p><strong> Example 2</strong></p>
<pre>
SELECT substrcount(
                `tablename` , ','
        ) as tablename
        FROM `tablename`
        where substrcount(
                `tablename` , ','
        ); </pre>
<p>The content of table named tablename is a comma separated list generated from mysql ENUM datatype </p>
<pre>
2000/2001,2001/2002,2002/2003,2003/2004,2004/2005,2005/2006,2006/2007,2007/2008,2008/2009,2009/2010</pre>
<p>In Example 2 the result from this query would be 9, telling us that there are 9 commas in this tablerow.</p>
<p><strong>Source:</strong> <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring-index">Posted by Andrew Hanna on August 24 2006 8:04pm</a></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.php.net\/manual\/en\/function.substr-count.php","http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/string-functions.html#function_substring-index"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDkvMTAvMjMvbXlzcWwtYWx0ZXJuYXRpdmUtdG8tcGhwLXN1YnN0cl9jb3VudC1mdW5jdGlvbi88d3B0Yj5teXNxbCBhbHRlcm5hdGl2ZSB0byBQSFAgc3Vic3RyX2NvdW50IGZ1bmN0aW9uPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2009/10/23/mysql-alternative-to-php-substr_count-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto combine two columns into one in mysql</title>
		<link>http://pario.no/2009/09/06/howto-combine-two-columns-into-one-in-mysql/</link>
		<comments>http://pario.no/2009/09/06/howto-combine-two-columns-into-one-in-mysql/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 21:10:37 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1195</guid>
		<description><![CDATA[This is how you can combine (or concatenate) data from two table columns into one column using a mysql SQL query. SELECT CONCAT(firstname,lastname) AS 'name' FROM tablename The result would be &#8220;firstname lastname&#8221; If you would like to insert this data into a new column INSERT INTO tablename (full_name) SELECT CONCAT(firstname,lastname) AS 'name' FROM tablename [...]]]></description>
			<content:encoded><![CDATA[<p>This is how you can combine (or concatenate) data from two table columns into one column using a mysql SQL query.</p>
<pre>
SELECT CONCAT(firstname,lastname) AS 'name' FROM tablename</pre>
<p>The result would be &#8220;firstname lastname&#8221;</p>
<p>If you would like to insert this data into a new column</p>
<pre>
INSERT INTO tablename (full_name) SELECT CONCAT(firstname,lastname) AS 'name' FROM tablename</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDkvMDkvMDYvaG93dG8tY29tYmluZS10d28tY29sdW1ucy1pbnRvLW9uZS1pbi1teXNxbC88d3B0Yj5Ib3d0byBjb21iaW5lIHR3byBjb2x1bW5zIGludG8gb25lIGluIG15c3FsPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2009/09/06/howto-combine-two-columns-into-one-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL search and replace</title>
		<link>http://pario.no/2008/12/15/mysql-search-and-replace-2/</link>
		<comments>http://pario.no/2008/12/15/mysql-search-and-replace-2/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 22:17:16 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://pario.no/?p=836</guid>
		<description><![CDATA[This is a simple SQL query to perform search and replace in a MySQL table update tablename set fieldname = replace(fieldname,'search_for_this','replace_with_this'); var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTIvMTUvbXlzcWwtc2VhcmNoLWFuZC1yZXBsYWNlLTIvPHdwdGI%2BTXlTUUwgc2VhcmNoIGFuZCByZXBsYWNlPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";]]></description>
			<content:encoded><![CDATA[<p>This is a simple SQL query to perform search and replace in a MySQL table</p>
<pre>update tablename set fieldname = replace(fieldname,'search_for_this','replace_with_this');</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTIvMTUvbXlzcWwtc2VhcmNoLWFuZC1yZXBsYWNlLTIvPHdwdGI%2BTXlTUUwgc2VhcmNoIGFuZCByZXBsYWNlPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/12/15/mysql-search-and-replace-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql on a nondefault socket</title>
		<link>http://pario.no/2008/10/08/mysql-on-anondefault-socket/</link>
		<comments>http://pario.no/2008/10/08/mysql-on-anondefault-socket/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 16:16:19 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[socket]]></category>

		<guid isPermaLink="false">http://pario.no/?p=511</guid>
		<description><![CDATA[It is sometimes necessary to run two instances of mysql, like in my case. I need a mysql database in addition to the one Zimbra uses. One solution to this problem is to run the mysql database on a non default socket. This can be done by changing the following line in my.cnf my.cnf [client] [...]]]></description>
			<content:encoded><![CDATA[<p>It is sometimes necessary to run two instances of mysql, like in my case. I need a mysql database in addition to the one Zimbra uses. One solution to this problem is to run the mysql database on a non default socket. This can be done by changing the following line in <strong>my.cnf</strong></p>
<p><strong>my.cnf</strong></p>
<pre>
[client]
...
socket = /var/run/mysqld/mysqld2.sock</pre>
<p>Restart the mysql daemon afterwards to activate the change.</p>
<p>In PHP it&#8217;s possible to avoid programming the nondefault socket info whenever we use mysql<br />
<strong>php.ini</strong></p>
<pre>
[MySQL]
...
mysql.default_socket = /var/run/mysqld/mysqld2.sock</pre>
<p>If you don&#8217;t have access to php.ini you have to program this in your PHP code</p>
<pre>
$dbcnx = @mysql_connect('localhost:/var/run/mysqld/mysqld2.sock',$username, $password);</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTAvMDgvbXlzcWwtb24tYW5vbmRlZmF1bHQtc29ja2V0Lzx3cHRiPm15c3FsIG9uIGEgbm9uZGVmYXVsdCBzb2NrZXQ8d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/10/08/mysql-on-anondefault-socket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
