<?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>Bri Manning&#039;s Blog &#187; SQL</title>
	<atom:link href="http://brimanning.com/blog/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://brimanning.com/blog</link>
	<description>A Developnerd&#039;s Take on Being Awesome</description>
	<lastBuildDate>Sun, 05 Sep 2010 12:22:40 +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>SQL Delete Mimicking Left Join</title>
		<link>http://brimanning.com/blog/sql-delete-left-join/</link>
		<comments>http://brimanning.com/blog/sql-delete-left-join/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 08:35:32 +0000</pubDate>
		<dc:creator>Brian Manning</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://staging.brimanning.com/blog/?p=4</guid>
		<description><![CDATA[It may seem a little silly, but sometimes I wish I could do something like a JOIN when I&#8217;m using DELETE. I came up with a workaround that does the job nicely (but maybe not efficiently, but hey, I don&#8217;t need to do this too often anyway). DELETE FROM first_table WHERE ft_id IN ( SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>
It may seem a little silly, but sometimes I wish I could do something like a <code>JOIN</code> when I&#8217;m using <code>DELETE</code>.  I came up with a workaround that does the job nicely (but maybe not efficiently, but hey, I don&#8217;t need to do this too often anyway).
</p>
<pre><code>DELETE FROM first_table WHERE ft_id IN (
  SELECT ft_id FROM first_table f
  LEFT JOIN second_table s ON s.ft_id = f.ft_id
  WHERE s.ft_id IS NOT NULL
  AND s.ft_id NOT IN (
    SELECT third_table.id
    FROM third_table
    WHERE id > 100))
</code></pre>
<p>
I like it because just by using a <code>IN</code> using a primary key you can select any particular entry you wanted to delete.  And it&#8217;s a whole lot safer because you can test by just using the <code>SELECT</code> by itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://brimanning.com/blog/sql-delete-left-join/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using an Insert-Select Statement</title>
		<link>http://brimanning.com/blog/select-with-insert/</link>
		<comments>http://brimanning.com/blog/select-with-insert/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 03:04:32 +0000</pubDate>
		<dc:creator>Brian Manning</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://staging.brimanning.com/blog/?p=10</guid>
		<description><![CDATA[So, one other thing I want to use this blog for is recording stuff that I forget all the time. I feel like it especially happens with SQL. Why? Not quite sure. I&#8217;m a big fan of ActiveRecord, so that gets me away from SQL, so that could be it. Anyway, I want to record [...]]]></description>
			<content:encoded><![CDATA[<p>
So, one other thing I want to use this blog for is recording stuff that I forget all the time.  I feel like it especially happens with <a href="/blog/categories/sql" title="T-SQL/MySQL">SQL</a>.  Why?  Not quite sure.  I&#8217;m a big fan of <a href="http://en.wikipedia.org/wiki/Active_record_pattern" title="ActiveRecord Database Interaction">ActiveRecord</a>, so that gets me away from SQL, so that could be it.
</p>
<p>
Anyway, I want to record it here because I always forget it: how to <code>INSERT</code> from one table using a <code>SELECT</code> from another table.
</p>
<pre><code>INSERT INTO sometable (acolumn, anothercolumn)
SELECT someothercolumn, onemorecolumn
FROM adifferenttable
</code></pre>
<p>
Real simple, but I always end up second-guessing myself (stupidly, I know).  Anyway, there it is so I won&#8217;t forget it&#8230;  Hopefully&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://brimanning.com/blog/select-with-insert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
