Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8740625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:09:46+00:00 2026-06-13T11:09:46+00:00

Hey all i have the following query: SELECT REPLACE(REPLACE(REPLACE(REPLACE(tmpTable.Caller_Number,’-‘,”),'(‘,”),’)’,”),’ ‘,”) FROM tmpTable WHERE EXISTS

  • 0

Hey all i have the following query:

SELECT REPLACE(REPLACE(REPLACE(REPLACE(tmpTable.Caller_Number,'-',''),'(',''),')',''),' ','') 
FROM tmpTable 
WHERE EXISTS 
(SELECT REPLACE(REPLACE(REPLACE(REPLACE(OnlineAppDetails.addPhone,'-',''),'(',''),')',''),' ','') 
FROM OnlineAppDetails 
WHERE OnlineAppDetails.addPhone = tmpTable.Caller_Number)
ORDER BY GroupsBy ASC;

It returns no records… However, when i do this query:

SELECT * 
FROM tmpTable 
WHERE EXISTS 
(SELECT * FROM OnlineAppDetails 
WHERE SUBSTRING(OnlineAppDetails.addPhone,2,3)+'-'+SUBSTRING(OnlineAppDetails.addPhone,7,4)+SUBSTRING(OnlineAppDetails.addPhone,11,4) = tmpTable.Caller_Number)
ORDER BY GroupsBy ASC;

It returns records..

The phome number is formatted like:

for OnlineAppDetails: (xxx) xxx-xxxx
for         tmpTable: xxx-xxx-xxxx

All i am doing is taking out the – ( ) and [space] in the phone number just to be sure i am being returned all the records i should be. I know there are matches in both tables so taking out – ( ) and [space] should still result in records returned.

update

Duh…. knew it was going to be simple.

SELECT * 
FROM tmpTable 
WHERE EXISTS 
(SELECT * 
FROM OnlineAppDetails 
WHERE  REPLACE(REPLACE(REPLACE(REPLACE(OnlineAppDetails.addPhone,'-',''),'(',''),')',''),' ','') = REPLACE(REPLACE(REPLACE(REPLACE(tmpTable.Caller_Number,'-',''),'(',''),')',''),' ',''))
ORDER BY GroupsBy ASC;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:09:47+00:00Added an answer on June 13, 2026 at 11:09 am

    For sure the first query wouldn’t return any rows:
    that is because, the WHERE OnlineAppDetails.addPhone = tmpTable.Caller_Number part of the inner query will yield zero rows (given the expect format of the respective fields), hence the EXISTS will always be false.
    Note BTW that the string manipulation done in the SELECT portion on this (indeed of any) EXISTS subquery, cannot have any effect on the result of the EXISTS predicate; that is why the idiom used is typically: ... WHERE EXISTS * FROM ....

    The second query query works because the string transformation is applied in the WHERE clause. This transformation makes the OnlineAppDetails.addPhone value have the same format as the format of the tmpTable.Caller_Number, hence providing a opportunity to find matches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I have a question on how to implement the following with Django.
Hey all, basically i have an empty AS3 fla file with just the following
Hey all. I have the following code: http://jsfiddle.net/g7Cgg/ As you can see, there are
Hey all, I have the following setup in my webroot: /issues (Trac install) /myapp
Hey all, I have the following problem. I recently added an extra column to
Hey guys I have the following sample. I have navigation which is loaded from
Hey I have been following gcm tutorial to create gcm-demo-server and a demo-client. All
hey all, Im stumped. I have the following code..works fine in all browsers except
Hey all i have code to write to an xml doc from asp string
Hey all i have the following code to change out an image and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.