SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: MySQL Question
-
Feb 25, 2001, 15:59 #1
Hello,
I have a MySQL database that stores a number of news items for my site. What I want to do is get the first 20 or so words from the database. I know you can get the first 20 or so characters, but how would I get the words ?
Thanks for any help
Sean
-
Feb 25, 2001, 16:26 #2
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How about:
SELECT SUBSTRING_INDEX(contentfieldname, ' ', 20) as shortext from tablename;Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Feb 25, 2001, 16:27 #3
- Join Date
- Nov 2000
- Location
- London, UK
- Posts
- 223
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If I were you, (although this is very inefficient), I would get the article whole, then in PHP write something that would return only what was before the 21st space (basically, 20 words .. although you might want to add some to count for spaces after periods and commas) but don't ask me how, 'cause I haven't got a clue.
Ask freddydoesphp ... feline knowledge always helps.
... what's the world coming to?
-
Feb 25, 2001, 16:31 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I say doing it in the query is not only accurate but more efficient.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Feb 25, 2001, 23:24 #5
- Join Date
- Apr 2000
- Location
- Melbourne, Australia
- Posts
- 2,571
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I say fredddy is right.
Kevin Yank
CTO, sitepoint.com
I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
Baby’s got back—a hard back, that is: The Ultimate CSS Reference
-
Feb 26, 2001, 03:17 #6
- Join Date
- Nov 2000
- Location
- London, UK
- Posts
- 223
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So do I ! Darnit why do these amateurs always try and come up with half-baked, low-quality solutions. It's REALLY ANNOYING
aherm. So do I... but somehow my glasses must have fogged up as I read the thread because I didn't notice freddy's reply when I replied ...
Hehe ... sorry 'bout that
... what's the world coming to?
Bookmarks