我想从sql的数据库中取一个字段内容中的一部分,请问如何操作呢/

在网页调用新闻的时候, 我想在在新闻列表的地方,加入新闻标题和一部分新闻内容,请问如果写这段代码。

---------------------------------------------------------------

取字符串的一部分用substr()函数
---------------------------------------------------------------

取定长
left(content,300)
或select case(content as char(300)) as content from yourtable
---------------------------------------------------------------

sql="select substring(字段名,字符起始位置,長度) from tablename"

example

sql="select substring(title,4,4) from tablename"
取title的第四個字符開始的四位字符

Published At
Categories with Web编程
Tagged with
comments powered by Disqus