PDA

View Full Version : first 50 words of a field


grudz
03-26-2004, 08:55 PM
hi,

i know that this question has been asked before, but i can't find the right keywords to search....

how would i write that i want the first 50 words of a field in something like this?

SELECT body
FROM news

raf
03-26-2004, 11:37 PM
Do you mean through an sql query? or through server side scripting?

grudz
03-27-2004, 02:16 AM
sql query....

raf
03-27-2004, 10:13 AM
don't think it is possible. Unless you think up some mad regex i don't immedeately see a possebility. So you'll need to selects the complete value (possibly with a left(var, 350) --> 50 * 7 which should be enough character to get 50 words, needs some experimenting) and then you need to process it further in PHP.