Jump to content

Is there such a function?


adam84

Recommended Posts

I have a column (text) where the user enters like a profile about themselves.

 

What I want to do is in the search results, I just want to grab the first 100 or so words from that column. Is there an sql function the would just return that or will I ahve to create a php function to do that?

 

Awesome!

 

Thanks

Link to comment
Share on other sites

Mysql has string functions that would allow you to return a specific number of characters (not words). You could form a more complex query that found the position of the 100'th white-space (assumes some kind of white space separates words) and then use that to return the characters up to that position. So, yes, you could do this in a query.

 

Since you commonly would provide a link to display all the information when clicked, retrieving all the information one time and just displaying a portion of it while keeping the whole content available (in a session or perhaps even in a hidden <div> on the page) would result in the best performance.

Link to comment
Share on other sites

Since you commonly would provide a link to display all the information when clicked, retrieving all the information one time and just displaying a portion of it while keeping the whole content available (in a session or perhaps even in a hidden <div> on the page) would result in the best performance.

 

As you are probably going to be displaying several extracts, then link to another page for the full article, I can't see the efficiency in getting the full text of all articles on that first page. The article wanted my not even be iin the first page so they're dragged down for no reason, slowing the query in the process.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.