Mac Forums

Mac Forums (
-   Web Design and Hosting (
-   -   mySQL question (

gort 09-27-2004 05:35 PM

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.

muso 09-27-2004 11:11 PM

Personally I'd use PHP:

Murlyn 09-28-2004 03:44 PM

Returns the leftmost len characters from the string str.

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

All times are GMT -4. The time now is 11:18 AM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.