www.webdeveloper.com
Results 1 to 4 of 4

Thread: Make a query for get partial text

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Posts
    39

    Make a query for get partial text

    hello

    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?

    thank

  2. #2
    Join Date
    Oct 2012
    Posts
    13
    Hi,
    just use substring function in you query, it will look like:
    Code:
    SELECT SUBSTRING(mytextarea,1,200) as `mytextarea` FROM `my_table` WHERE `user_id`=[user_id]
    It should be something like that, but I'm not 100% sure

  3. #3
    Join Date
    Oct 2012
    Posts
    13
    Sorry, i dont know how to edit the post, but I have made a wrong there, it should be:
    Code:
    SELECT SUBSTRING(mytextarea,1,200) FROM `my_table` WHERE `user_id`=[user_id]

  4. #4
    Join Date
    Mar 2011
    Posts
    39

    resolved

    sorry guy I forget to thank you

    Yes now all is fine for me. In my case the following query do the job:

    Code:
    SELECT SUBSTRING(`myfieldname`,1,200) FROM `mytable` WHERE `user_id` = '[user_id]'
    all the best

    cheers
    Last edited by dotcom22; 11-16-2012 at 09:01 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles