<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[MySQL字符串中数字排序的问题，mysql 的 find_in_set函数使用方法。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[数据库技术]]></category>
<pubDate>Tue, 03 Nov 2015 01:44:45 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：一外包项目其字段名为order，且是字符串，还order by order，这样的一个搞法，为此，这块Mysql通过sql排序是有问题的，因为里面存的是整数，这块直接修改表为整数也就Ok了。<br/>MySQL字符串相信大家都不陌生，在MySQL字符串排序时经常会遇到一些问题，比如下面的这<br/>今天解决了一个关于MySQL字符串排序的很奇怪的问题,在数据里面定义的是varchar类型,实际存放的是Int类型的数据,按一下查询语句进行排序:<br/>将字段*1或者+0可以将MySQL字符串字段按数值排序<br/>如:<br/>select * from table where 1 order by id*1 desc; <br/>或者<br/>select * from table where 1 order by id+0 desc; <br/>除了上述方法外，这里附上一种排序方法,利用find_in_set()进行无敌排序<br/>附上Mysql函数 find_in_set() 的用法:<br/>-------------------------------------------------------<br/>举个例子来说： <br/>有个文章表里面有个type字段,他存储的是文章类型,有 1头条,2推荐,3热点,4图文 .....11,12,13等等 <br/>现在有篇文章他既是 头条,又是热点,还是图文, <br/>type中以 1,3,4的格式存储. <br/>们我们如何用sql查找所有type中有4图文标准的文章呢？？ <br/><br/>这就要我们的find_in_set出马的时候到了. <br/>以下为引用的内容： <br/>select * from article where FIND_IN_SET(&#039;4&#039;,type) <br/>FIND_IN_SET(str,strlist) <br/>Returns a value 如果字符串 str 在由 N 个子串组成的列表 strlist 中，返回一个 1 到 N 的值。一个字符串列表是由通过字符 “,” 分隔的多个子串组成。如果第一个参数是一个常数字符串，并且第二个参数是一个 SET 列类型，FIND_IN_SET() 函数将被优化为使用位运算！如果 str 在不 strlist 中或者如果 strlist 是一个空串，返回值为 0。如果任何一个参数为 NULL，返回值也是 NULL。如果第一个参数包含一个 “,”，这个函数将完全不能工作：<br/>mysql&gt; SELECT FIND_IN_SET(&#039;b&#039;,&#039;a,b,c,d&#039;); <br/>-&gt; 2 <br/>for example: <br/>$sql = &quot;select p.*, find_in_set(p.products_id,$string_hot_pid) as rank from products p where p.products_id in ($string_hot_pid) order by rank&quot;; <br/>大家有什么好的想法和建议可以留下宝贵的意见 以便共同进步<br/>来自：http://www.cnblogs.com/yhyjy/archive/2012/07/25/2607818.html<br/>http://1055592535.iteye.com/blog/1674734
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] MySQL字符串中数字排序的问题，mysql 的 find_in_set函数使用方法。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>