Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

trim

New Here ,
May 06, 2008 May 06, 2008
Hi.I have a table with a field wich has these values:
Top Low-Carb Products
Top Fat-Burners
Top Fat-Burners
...

how can I get rid of "Top" at the beging of each row?
thanks
TOPICS
Getting started
423
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2008 May 06, 2008
If your db has string functions, use one in your select clause.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2008 May 06, 2008
but I need to do it in the code.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2008 May 06, 2008
in code you could use mid() or right() functions...

but i would also, as Dan suggested, rather do it in the query using db's
string manipulation functions (in many dbs they have same names - MID(),
RIGHT()... check your db's sql syntax manual). then your db does the
work instead of cf = not wasting cf processing time.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2008 May 06, 2008
The query in your sql is part of your code. But, the more I think about it, you probably want this logic

if the 1st four characters are "Top "
do something to get rid of it. RemoveChars might work.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 07, 2008 May 07, 2008
<CFIF #Left(StringName,4)# = 'Top '>
<CFSET NewString = #Replace(StringName, "Top ", "")#>
<CFELSE>
<CFSET NewString = #StringName#>
</CFIF>

#NewString#
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 07, 2008 May 07, 2008
LATEST
thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources