Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

How to trim text in my query ?

8:15 am on Oct 23, 2012 (gmt 0)

New User

joined:Oct 23, 2012
votes: 0


I need to make a query (mysql database) for get the content of a specific texarea field. For do that I use the follow query:

SELECT `mytextareacolumn` FROM `my_table` WHERE `user_id` = [user_id]

Using this query allow me to get the full content of the texarea for each of my users but my goal was to get only the first 200 character and not the full text. Somebody told me is possible to do something using the SQL functions such as SUBSTR but I don't know how to include this function in my query.

I'm not a coder just a poor newbie.

Anybody can suggest me something please?

9:04 am on Oct 23, 2012 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 67

(returns) a substring len characters long from string str, starting at position pos

SELECT SUBSTRING(`mytextareacolumn`,0,200) AS `mytextarea200` FROM `my_table` WHERE `user_id` = [user_id]
3:00 pm on Nov 16, 2012 (gmt 0)

New User

joined:Oct 23, 2012
posts: 2
votes: 0

sorry guy I forget to thank you for pointing to me on the right direction :-(

In my case the follow code do the job:

SELECT SUBSTRING(`myfieldname`,1,200) FROM `mytable` WHERE `user_id` = '[user_id]'

all the best


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members