Skip to main content
Known Participant
June 19, 2009
Answered

Cfquery help..

  • June 19, 2009
  • 2 replies
  • 476 views

Hi guys,

           I am pulling data from a table which has 3 columns name, description and id, I want to display only top 20 char from descrption and a link when they click it will give entire description, I am not sure how to restrict to daisply only 20 char,...

Thanks you

    This topic has been closed for replies.
    Correct answer craigkaminsky

    If you're looking to limit the characters in your output (as opposed to doing it at the DB-level), you can just use something like the following:

    <cfset only20 = Left( myquery.description, 20 ) />

    The string function Left() returns the X most characters from a String.

    2 replies

    Inspiring
    June 19, 2009

    Different db's have different functions that allow you to do this in your query.  These functions have names like left(), or substr().  google "your db string functions" to see what's available to you.

    craigkaminskyCorrect answer
    Inspiring
    June 19, 2009

    If you're looking to limit the characters in your output (as opposed to doing it at the DB-level), you can just use something like the following:

    <cfset only20 = Left( myquery.description, 20 ) />

    The string function Left() returns the X most characters from a String.