<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>みぞおち &#187; SQL</title>
	<atom:link href="http://mizoochi.com/categories/sql/feed" rel="self" type="application/rss+xml" />
	<link>http://mizoochi.com</link>
	<description>日々の足跡をコツコツと</description>
	<lastBuildDate>Mon, 08 Feb 2010 17:26:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://mizoochi.com/categories/sql/feed" />
		<item>
		<title>レスが付いたらスレッドを上に上げるSQL</title>
		<link>http://mizoochi.com/archives/212.html</link>
		<comments>http://mizoochi.com/archives/212.html#comments</comments>
		<pubDate>Fri, 22 Feb 2008 00:00:00 +0000</pubDate>
		<dc:creator>mizota</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[制作]]></category>

		<guid isPermaLink="false">http://mizoochi.com/archives/212</guid>
		<description><![CDATA[SQLをある程度書けるとPHPやほかのプログラムの書く量が減ると思う。
実際サブクエリーやSQL関数が使えるだけで随分違う。
最近やっとサブクエリの重要さに気づいて取り組んでいる。
とある掲示板システムでのサンプル
レス [...]]]></description>
			<content:encoded><![CDATA[<p>SQLをある程度書けるとPHPやほかのプログラムの書く量が減ると思う。<br />
実際サブクエリーやSQL関数が使えるだけで随分違う。<br />
最近やっとサブクエリの重要さに気づいて取り組んでいる。<br />
とある掲示板システムでのサンプル</p>
<p><strong>レスが付いたらスレッドを上に上げるSQL</strong></p>
<div style="position:relative;top:18px;margin-top:-18px;"><small><strong>SQL</strong></small></div>
<pre class="brush: sql; auto-links: false; font-size: 80%;" style="margin:18px 0;">
SELECT *,(SELECT MAX(T2.update_time) FROM entry_tbl as T2 WHERE T2.resflg=T1.ID) as uptime FROM entry_tbl as T1 WHERE resflg=0 ORDER BY uptime DESC,T1.update_time DESC
</pre>
<p>ここでのresflgは本スレの場合、0が立つ。<br />
レスの場合はIDに紐付けするのでresflgには本スレと同じID番号が入る。<br />
上記だけだとレスの表示処理が入っていないので、もっとカスタマイズすれば<br />
レスも合わせて表示出来る処理に出来そう。。実力不足のため4時間ほど粘ったが思いつかず。<br />
MAX関数はそのフィールド内での最大値取得。</p>
<p>今回収穫は<span style="color:#CC3333;">ORDER BYで複数フィールドが指定出来るという事に気づいた事</span>。<br />
今までは1フィールドしか指定してなかったからなぁ…SQL奥深い。。</p>
<h3>Popular Posts:</h3>
<ul class="popular-posts txt75">
<li class="txt75"><a href="http://mizoochi.com/archives/126.html" rel="bookmark" title="2008 年 11 月 27 日">jQuery ifによる要素の判定</a></li>
<li class="txt75"><a href="http://mizoochi.com/archives/145.html" rel="bookmark" title="2008 年 12 月 2 日">一新。</a></li>
<li class="txt75"><a href="http://mizoochi.com/archives/734.html" rel="bookmark" title="2009 年 8 月 9 日">iframe等を使った子から親へイベントを渡す方法</a></li>
<li class="txt75"><a href="http://mizoochi.com/archives/211.html" rel="bookmark" title="2008 年 2 月 21 日">いつも忘れちゃうので&#8230;UNIXタイムスタンプの変換</a></li>
<li class="txt75"><a href="http://mizoochi.com/archives/216.html" rel="bookmark" title="2008 年 3 月 21 日">JSONデータの使い方</a></li>
</ul>
<p><!-- popular Posts took 3.065 ms --></p>
Similar Posts:<ul><li><a href="http://mizoochi.com/archives/211.html" rel="bookmark" title="2008 年 2 月 21 日">いつも忘れちゃうので&#8230;UNIXタイムスタンプの変換</a></li>

<li><a href="http://mizoochi.com/archives/339.html" rel="bookmark" title="2009 年 2 月 3 日">ImageProtecter公開ページを更新。</a></li>

<li><a href="http://mizoochi.com/archives/213.html" rel="bookmark" title="2008 年 2 月 28 日">addEventListenerの第二引数について</a></li>

<li><a href="http://mizoochi.com/archives/312.html" rel="bookmark" title="2009 年 1 月 22 日">popenによるメール送信とPHPセーフモード</a></li>

<li><a href="http://mizoochi.com/archives/546.html" rel="bookmark" title="2009 年 5 月 23 日">タイ飯</a></li>
</ul><!-- Similar Posts took 3.941 ms -->]]></content:encoded>
			<wfw:commentRss>http://mizoochi.com/archives/212.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://mizoochi.com/archives/212.html" />
	</item>
	</channel>
</rss>

