Once, a former colleague (a small mm) asked me a question: she wanted to display a list of posts in a Web page, but given that some of the headings were too long and aesthetically pleasing, you would want to refer to the styles on other sites and replace them with ellipses, but you didn't know how to do them. So think of me (alas, when I need to think of me, Woo ...) )
After getting the title, I decided to start from the database, write query statements to achieve, the results are as follows:
Description statement:
SELECT (Left (original field, number of digits) + ' ... ') as new field
From table name WHERE datalength (original field) > digits
UNION All
SELECT the original field as new field from table name WHERE datalength (original field) <= number of digits
It was later considered that access does not support the datalength () function, so it is Len (), but in this case, the Chinese text counts as one, not the original two digits.
Last written:
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) T emptable where kind= ' Activity Bulletin ' O