<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Add Foreign Key in phpMyAdmin</title>
	<atom:link href="http://ivan-grace.com/techblog/2009/01/add-foreign-key-in-phpmyadmin/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivan-grace.com/techblog/2009/01/add-foreign-key-in-phpmyadmin/</link>
	<description></description>
	<lastBuildDate>Mon, 22 Jun 2009 17:13:48 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ivan Guan</title>
		<link>http://ivan-grace.com/techblog/2009/01/add-foreign-key-in-phpmyadmin/comment-page-1/#comment-66</link>
		<dc:creator>Ivan Guan</dc:creator>
		<pubDate>Sat, 09 May 2009 17:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://ivan-grace.com/techblog/2009/01/add-foreign-key-in-phpmyadmin/#comment-66</guid>
		<description>If you already have the tables somewhere (perhaps in a temporary, non-relational setup), you can use a left join to find &quot;orphaned&quot; rows. This will find records in $t1 that refer to non-existant rows in $t2. Just fill in the variables.

SELECT t1.$key
FROM $t1 AS t1
LEFT JOIN $t2 AS t2
ON t1.$foreign_key = t2.$key
WHERE t2.$key IS NULL</description>
		<content:encoded><![CDATA[<p>If you already have the tables somewhere (perhaps in a temporary, non-relational setup), you can use a left join to find &#8220;orphaned&#8221; rows. This will find records in $t1 that refer to non-existant rows in $t2. Just fill in the variables.</p>
<p>SELECT t1.$key<br />
FROM $t1 AS t1<br />
LEFT JOIN $t2 AS t2<br />
ON t1.$foreign_key = t2.$key<br />
WHERE t2.$key IS NULL</p>
]]></content:encoded>
	</item>
</channel>
</rss>
