Lyricsride Posted November 6, 2006 Share Posted November 6, 2006 Hey there, this is a simple question but i can't seem to find the answer. Probably b/c i don't know what to specifically search for the answer.I want to query a subset of a text field. In my newsposts i want the "preview" of the text to be shown on an index page with all news posts. I'd rather do this than have to text fields (text_short, text_long).The concept would be: SELECT <field> FROM <table> WHERE <only first 30 words of the field>Simple, i think, what concept should i be searching out here?Thanks guys, really appreciate it. Quote Link to comment Share on other sites More sharing options...
Mattyspatty Posted November 6, 2006 Share Posted November 6, 2006 i think i understand, you want a preview like:welcome to my page, some of the text has been removed to make it shorter!shows aswelcome to my page, some...you can use this => [url=http://uk2.php.net/substr]http://uk2.php.net/substr[/url] Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2006 Share Posted November 6, 2006 [code]SELECT SUBSTRING('fld',30) FROM tbl;[/code] Quote Link to comment Share on other sites More sharing options...
Lyricsride Posted November 6, 2006 Author Share Posted November 6, 2006 Thanks guys this is great! Is it better to use php or SQL to do this? I suppose it depends, in my case i probably want to go with speed right? So which should be faster? Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2006 Share Posted November 6, 2006 MySql should be the prefered option. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.