Jump to content


Photo

Number of characters in an SQL Field


  • Please log in to reply
3 replies to this topic

#1 Jayso

Jayso
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 April 2006 - 06:11 AM

Is there a SQL or PHP function that can tell me how many characters there are in a certain field of text? (i assume there is)

#2 dedart

dedart
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationNewcastle Australia

Posted 23 April 2006 - 06:15 AM

[a href=\"http://au2.php.net/strlen\" target=\"_blank\"]http://au2.php.net/strlen[/a]
Count the number of characters in a string!

Google is good too when u wanna find these things:
[a href=\"http://www.google.com/search?q=php+count+characters&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official\" target=\"_blank\"]http://www.google.com/search?q=php+count+c...:en-US:official[/a]

#3 Jayso

Jayso
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 April 2006 - 06:42 AM

Thanks mate

#4 ypirc

ypirc
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 23 April 2006 - 07:24 AM

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] LENGTH(column) FROM table [!--sql2--][/div][!--sql3--]
OR
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] CHAR_LENGTH(column) FROM table [!--sql2--][/div][!--sql3--]


From: [a href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/string-functions.html[/a]

[quote]

CHAR_LENGTH(str)

Returns the length of the string str, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.

CHARACTER_LENGTH(str)

CHARACTER_LENGTH() is a synonym for CHAR_LENGTH().

[/quote




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users