Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   Web Design and Hosting (http://www.mac-forums.com/forums/web-design-hosting/)
-   -   mySQL question (http://www.mac-forums.com/forums/web-design-hosting/9697-mysql-question.html)

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: http://www.php.net/substr

Murlyn 09-28-2004 03:44 PM

LEFT(str,len)
Returns the leftmost len characters from the string str.

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


All times are GMT -4. The time now is 12:11 PM.

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