<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>MySQL</title>
  <link rel="alternate" type="text/html" href="http://addingunderstanding.com/category/mysql"/>
  <link rel="self" type="application/atom+xml" href="http://addingunderstanding.com/taxonomy/term/138/atom/feed"/>
  <id>http://addingunderstanding.com/taxonomy/term/138/atom/feed</id>
  <updated>2006-08-22T20:22:48-06:00</updated>
  <entry>
    <title>Occam&#039;s razor applies to technology too</title>
    <link rel="alternate" type="text/html" href="http://addingunderstanding.com/2008/01/occams-razor-applies-technology-too" />
    <id>http://addingunderstanding.com/2008/01/occams-razor-applies-technology-too</id>
    <published>2008-01-23T19:05:45-07:00</published>
    <updated>2008-01-23T21:21:27-07:00</updated>
    <author>
      <name>joshb</name>
    </author>
    <category term="MySQL" />
    <category term="System Administration" />
    <category term="WordPress" />
    <summary type="html"><![CDATA[<p>Sometimes it takes a simple reminder that Occam's razor or the <em>keep it simple stupid</em> principles apply to most things in the technical realm just as it does to the real world.</p>
<p>In the server meltdown last week the data was all recovered but some problems with the backups made it impossible to get all of the file directories. The net result was a friend's <a href="http://blog.notruebill.com/?p=535">WordPress blog melted down</a>. Or at least all the goodies were gone. In the process of renewing the site and getting it updated a tagging plugin no-longer worked. As we talked this afternoon I looked through the database and figured out the schema and what was happening. Quickly enough I hit on a few simple queries and realized I could convert the data.</p>
<p>After another backup of the database it was time to set about migrating the data. The first query is:</p>
<div class="codeblock">INSERT IGNORE into wp_terms (slug, name, term_id) SELECT lower(replace(replace(replace(wp_tags.tag, &#039;.&#039; , &#039;&#039;), &quot;&#039;&quot;, &quot;&quot;), &quot;\\&quot;, &#039;&#039;)) a, replace(replace(wp_tags.tag, &#039;-&#039;, &#039; &#039;), &#039;_&#039;, &#039; &#039;) b, NULLFROM wp_tags</div>
<p>That runs perfectly and it was time for step two. Or it was really time for step one. Not a major WordPress user I am not terribly familiar with the community. But it hit me that I was probably not the first person to be doing this. Maybe somebody else had published the SQL to make this process easier.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Sometimes it takes a simple reminder that Occam's razor or the <em>keep it simple stupid</em> principles apply to most things in the technical realm just as it does to the real world.</p>
<p>In the server meltdown last week the data was all recovered but some problems with the backups made it impossible to get all of the file directories. The net result was a friend's <a href="http://blog.notruebill.com/?p=535">WordPress blog melted down</a>. Or at least all the goodies were gone. In the process of renewing the site and getting it updated a tagging plugin no-longer worked. As we talked this afternoon I looked through the database and figured out the schema and what was happening. Quickly enough I hit on a few simple queries and realized I could convert the data.</p>
<p>After another backup of the database it was time to set about migrating the data. The first query is:</p>
<div class="codeblock">INSERT IGNORE into wp_terms (slug, name, term_id) SELECT lower(replace(replace(replace(wp_tags.tag, &#039;.&#039; , &#039;&#039;), &quot;&#039;&quot;, &quot;&quot;), &quot;\\&quot;, &#039;&#039;)) a, replace(replace(wp_tags.tag, &#039;-&#039;, &#039; &#039;), &#039;_&#039;, &#039; &#039;) b, NULLFROM wp_tags</div>
<p>That runs perfectly and it was time for step two. Or it was really time for step one. Not a major WordPress user I am not terribly familiar with the community. But it hit me that I was probably not the first person to be doing this. Maybe somebody else had published the SQL to make this process easier. </p>
<p>Well maybe, just maybe, somebody had published a whole <a href="http://www.lifespy.com/2007/how-to-switch-from-ultimate-tag-warrior-to-wordpress-23-tagging/">how-to</a> document that shows the process is as simple as clicking next five times. The funny part is I'm always the one telling people to Google their tech issues first and even with that maxim it is easy to get so focused on a problem that one forgets to step back and look at the problem from a distance.</p>
    ]]></content>
  </entry>
  <entry>
    <title>MySQL views and MS Access</title>
    <link rel="alternate" type="text/html" href="http://addingunderstanding.com/mysql_access_views_problem.html" />
    <id>http://addingunderstanding.com/mysql_access_views_problem.html</id>
    <published>2006-08-29T00:05:17-06:00</published>
    <updated>2006-08-29T00:05:17-06:00</updated>
    <author>
      <name>joshb</name>
    </author>
    <category term="MySQL" />
    <summary type="html"><![CDATA[<p>So the CASE... WHEN solution posted previously works very well for MySQL. Lots of nice views popping up and  databases going forward.</p>
<p>However, when attempting to link a view as a table in Microsoft Access the calculated columns won't show. It's a real drag as it is such quick work to use views to de-normalize data for backwards compatibility.</p>
<p>Enter the <a href="http://support.microsoft.com/kb/303968/">pass-through query</a> which solves this problem as long as having the data in an Access query is suitable.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>So the CASE... WHEN solution posted previously works very well for MySQL. Lots of nice views popping up and  databases going forward.</p>
<p>However, when attempting to link a view as a table in Microsoft Access the calculated columns won't show. It's a real drag as it is such quick work to use views to de-normalize data for backwards compatibility.</p>
<p>Enter the <a href="http://support.microsoft.com/kb/303968/">pass-through query</a> which solves this problem as long as having the data in an Access query is suitable.</p>
    ]]></content>
  </entry>
  <entry>
    <title>CASE.... WHEN</title>
    <link rel="alternate" type="text/html" href="http://addingunderstanding.com/2006/08/case-when" />
    <id>http://addingunderstanding.com/2006/08/case-when</id>
    <published>2006-08-24T23:31:31-06:00</published>
    <updated>2006-08-24T23:31:31-06:00</updated>
    <author>
      <name>joshb</name>
    </author>
    <category term="MySQL" />
    <summary type="html"><![CDATA[<p>The answer to my <a href="http://addingunderstanding.com/node/1175">previous post</a> comes in the form of the <a href="http://dev.mysql.com/doc/refman/5.0/en/case-statement.html">CASE</a> statement in MySQL. </p>
<p>Basically SELECT (CASE WHEN alt_grade = &#039;&#039; THEN grade ELSE alt_grade END).</p>
<p>On another matter, am I the only one who is having terrible performance from the MySQL site online? During the day it's reminiscent of the good old dial-up-modem days.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>The answer to my <a href="http://addingunderstanding.com/node/1175">previous post</a> comes in the form of the <a href="http://dev.mysql.com/doc/refman/5.0/en/case-statement.html">CASE</a> statement in MySQL. </p>
<p>Basically SELECT (CASE WHEN alt_grade = &#039;&#039; THEN grade ELSE alt_grade END).</p>
<p>On another matter, am I the only one who is having terrible performance from the MySQL site online? During the day it's reminiscent of the good old dial-up-modem days.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Select IF...</title>
    <link rel="alternate" type="text/html" href="http://addingunderstanding.com/2006/08/select-if" />
    <id>http://addingunderstanding.com/2006/08/select-if</id>
    <published>2006-08-22T20:22:48-06:00</published>
    <updated>2006-08-22T20:22:48-06:00</updated>
    <author>
      <name>joshb</name>
    </author>
    <category term="MySQL" />
    <summary type="html"><![CDATA[<p>So today's brain teaser, how to best select either column A or column B in MySQL. Here's the setup. We have three columns that count. They are:</p>
<ul>
<li>Name</li>
<li>Grade</li>
<li>Alt. Grade</li>
</ul>
<p>In most rows there is a <i>grade</i> and no <i>alt. grade</i>. But every once in a while there are both a <i>grade</i> and an <i>alt. grade</i>. If it were an either-or case it would be simple. But it's an either-and. The question of the day is how to best accomplish it in MySQL 5.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>So today's brain teaser, how to best select either column A or column B in MySQL. Here's the setup. We have three columns that count. They are:</p>
<ul>
<li>Name</li>
<li>Grade</li>
<li>Alt. Grade</li>
</ul>
<p>In most rows there is a <i>grade</i> and no <i>alt. grade</i>. But every once in a while there are both a <i>grade</i> and an <i>alt. grade</i>. If it were an either-or case it would be simple. But it's an either-and. The question of the day is how to best accomplish it in MySQL 5.</p>
    ]]></content>
  </entry>
</feed>
