select - mysql retrieve partial column -
i using tinymce allow users write in submitted database.
tinymce includes button insert "pagebreak" (actually html comment <!--pagebreak-->
).
how can later pull first occurrence of pagebreak "tag"? there might significant bit of data after tag discard via php later, seems shouldn't bring back. can select
part of column if never know how far in data <!--pagebreak-->
be?
edit: below answer work, , me need go.. curious if there equally simple way handle bringing whole column if short , pagebreak tag doesn't exist. below solution, if no pagebreak found, empty string returned.
if not, can handle in code.
something should <!--
:
select substring(my_col 1 position('<!--' in my_col)-1) a_chunk my_table
edit:
putting omg ponies' words sql:
select case when position('<!--' in my_col) > 0 substring(my_col 1 position('<!--' in my_col)-1) else my_col end a_chunk my_table
it sounds you'll want check on length of text; whether or not there page break. can use character_length()
that.
Comments
Post a Comment