拿到題目后,我決定從數據庫來著手,寫查詢語句來實現,結果如下:
說明語句:
select (left(原字段,位數)+'...') as 新字段
from 表名 where datalength(原字段)>位數
union all
select 原字段 as 新字段 from 表名 where datalength(原字段)<=位數
后來考慮到access中不支持datalength()函數,所以改為len(),不過這樣的話,中文字也算作一位,而不是原來的兩位。
最后寫成:
select top 5 * from(
select id,(left([description],25)+'...') as descriptionx,kind,datetime, description, author, hit from [xjx] where len(description)>25
union all
select id,description as descriptionx,kind,datetime, description, author, hit from [xjx] where len(description)<=25) temptable where kind='活動簡報' o
新聞熱點
疑難解答