sql - Database character limit on the end of word? -
ok, know can limit size of characters of table field while fetching, of times split comes in middle of word:
select id, title, left(contents, 300) contents posts
now, possible make split come after word (at space)?
thank you
if using sql server, can like:
select id, title, left(contents, (case when charindex(contents, ' ', 300) > 0 charindex(contents, ' ', 300) else 300 end) ) contents posts;
in mysql:
select id, title, left(contents, (case when locate(' ', contents, 300) > 0 locate(' ', contents, 300) else 300 end) ) contents posts;
other databases have similar functions.
Comments
Post a Comment