Results 1 to 3 of 3

Thread: mySQL question

  1. #1
    mySQL question

    Member Since
    Jul 25, 2004
    Location
    Gaithersburg, MD
    Posts
    389
    Specs:
    Mac Pro 2.6ghz Quad Xeon, 23" Cinema
    mySQL question
    I was wondering how to only get the first x number of characters in an SQL query. Like if you have a field called job_description and you want to only display the first 50 chars or so as a "preview." Do you think it would be easier to use a built-in PHP function to crop it or is there a way to do it with the select statement. I don't have any of my reference books handy so I can't look it up.

  2. #2
    mySQL question
    muso's Avatar
    Member Since
    Jan 15, 2003
    Location
    Whangarei, New Zealand
    Posts
    2
    Specs:
    Pwnt
    Personally I'd use PHP: http://www.php.net/substr
    I'm in your forums, writing sentences in a grammatically acceptable manner.

  3. #3
    mySQL question
    Murlyn's Avatar
    Member Since
    Jun 11, 2003
    Location
    Mount Vernon, WA
    Posts
    4,915
    Specs:
    MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
    LEFT(str,len)
    Returns the leftmost len characters from the string str.

    mysql> SELECT LEFT('foobarbar', 5);
    -> 'fooba'

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. mySQL
    By burnedfaceless in forum Web Design and Hosting
    Replies: 1
    Last Post: 02-03-2014, 08:36 AM
  2. PHP MySql Security Question
    By mguise in forum Web Design and Hosting
    Replies: 0
    Last Post: 07-06-2011, 05:39 PM
  3. question about installing MySQL on a mac
    By hintbanana in forum Web Design and Hosting
    Replies: 3
    Last Post: 02-06-2008, 04:03 AM
  4. MySQL question
    By Dark Phoenix in forum Web Design and Hosting
    Replies: 4
    Last Post: 04-11-2005, 06:54 PM
  5. MySQL
    By ftjogoh in forum Web Design and Hosting
    Replies: 3
    Last Post: 11-21-2004, 11:29 AM

Posting Permissions

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