日期:2014-05-17  浏览次数:20702 次

高手在哪里,请赐教啊!
select RPAD(substring(b.Name,1,1),3,'*') as Name,a.NoteID as NoterID, a.Noter as Noter, a.Title as Title,
IFNULL(CONVERT(a.Body USING utf8), "") as "Body",
DATE_FORMAT(a.NoteTime,'%Y-%m-%d %H:%i:%s') as "CreateTime"
from T_SYS_NOTES as a join T_C_CUSTOMERS as b on a.Noter=b.CustomerID 
where 20121116140409 in(a.NoteID, a.ParentNoteID) and a.Status=0 and a.ParentNoteID not in (0)
union all
select "游客" as Name, a.NoteID as NoterID, a.Noter as Noter, a.Title as Title, 
IFNULL(CONVERT(a.Body USING utf8), "") as "Body", 
DATE_FORMAT(a.NoteTime,'%Y-%m-%d %H:%i:%s') as "CreateTime" 
from T_SYS_NOTES as a where 20121116140409 in(a.NoteID, a.ParentNoteID) 
and a.Status=0 and a.Noter is null and a.ParentNoteID not in (0) 
order by CreateTime asc limit 10;
这个语句能在数据执行并显示全部的字段,但是当我在action中打印时Name字段显示不出任何东西来,这是为什么,我用的mybatis的框架
------解决方案--------------------
效率建议:不要用not in 用not exists
------解决方案--------------------
这个更合适一点
http://www.cnblogs.com/wushiqi54719880/archive/2011/07/26/2117601.html