473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

obtain a substring from the result set

Hi, I have a query that returns the concatenation of two strings from two separate tables. 'site' and 'clicktrail'


Expand|Select|Wrap|Line Numbers
  1. SELECT CONCAT(a.file_prefix, b.file_name) as filePrefix from site a, clicktrail b 
  2. WHERE a.id = b.site_id 
  3. AND a.name='Unique Name'
say it returns the following

filePrefixA_
filePrefixB_
filePrefixC_

I need to remove the underscore from the end of each row, so the result would be

filePrefixA
filePrefixB
filePrefixC

I've been playing around with the SUBSTRING function, but I can't get the correct results, any help is greatly appreciated.
Oct 28 '07 #1
1 1213
amitpatel66
2,367 Expert 2GB
Hi, I have a query that returns the concatenation of two strings from two separate tables. 'site' and 'clicktrail'


SELECT CONCAT(a.file_prefix, b.file_name) as filePrefix from site a, clicktrail b
WHERE a.id = b.site_id
AND a.name='Unique Name'

say it returns the following

filePrefixA_
filePrefixB_
filePrefixC_

I need to remove the underscore from the end of each row, so the result would be

filePrefixA
filePrefixB
filePrefixC

I've been playing around with the SUBSTRING function, but I can't get the correct results, any help is greatly appreciated.
Use REPLACE function as shown below:
Expand|Select|Wrap|Line Numbers
  1. SELECT REPLACE(CONCAT(a.file_prefix, b.file_name),'_','') as filePrefix from site a, clicktrail b 
  2. WHERE a.id = b.site_id 
  3. AND a.name='Unique Name'
  4.  
Oct 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: comp.lang.php | last post by:
/** * Filter results according to given instruction * * @access private * @param object $result (reference) * @return object $filteredResult */ function &filterResults(&$result) { //...
7
by: Radhika Sambamurti | last post by:
Hi, I've written a substring function. The prototype is: int substr(char s1, char s2) Returns 1 if s2 is a substring of s1, else it returns 0. I have written this program, but Im sure there is an...
6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
3
by: Tim Soliday | last post by:
I have been looking at regular expressions lately, and I'm hoping that maybe someone could help me? I am trying to find the position of a substring, and then returning the substring including...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
2
by: David Filion | last post by:
Hi, I have a question about substring(), when I run the following query: prepaid=# select substring('15148300', 0, 5); substring ----------- 1514 (1 row)
8
by: gmclee | last post by:
Hi there, I need a program to extract a substring from the following pattern xxxx<XXXXX>xxxx therer, x and X are any character and the string between < and is what I need. I use the following...
4
by: Jean-François Michaud | last post by:
Hello, I've been looking at this for a bit now and I don't see what's wrong with the code. Can anybody see a problem with this? Here is an XSLT snippet I use. <xsl:template match="graphic">...
1
by: VictorG | last post by:
Hello, The below C# code works fine in obtaining the windows user's account SID when the user is local to the machine. It throws a "Not Found" exception when trying top obtain the SID for a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.