Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Exact string match and replace in SQL??

Posted on 2008-10-01
3
Medium Priority
?
2,305 Views
Last Modified: 2008-10-01
Hi,

This column called Destinations has country names like Cananda,France or Iran/Syria.
I am trying to replace those with the trigraphs.
How do I match exact string??

I changed Iran to IRQ then I had a few IR. so when I replace IR with IRQ.
Previous IRQ became, IRQQ.

Is it possible to match exactly string not partial??

I used update table set location=replace(location, 'sss','dffdf')

Thannks

0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 1400 total points
ID: 22619061
Use the WHERE clause for an exact match on the string:

UPDATE tbl SET location = 'sss'
WHERE location = 'dffdf';
0
 
LVL 39

Assisted Solution

by:BrandonGalderisi
BrandonGalderisi earned 600 total points
ID: 22619295
This won't be the most efficient because it will update Location = location for all records that you don't specify.... but it give you the idea on how to build it out.
update YourTable
set Location = case location when 'IR' then 'IRQ'
                                when 'IRAN/SYRIA' then 'IRN'
                                when 'Canada' then 'CAN'
                                else location
end

Open in new window

0
 

Author Comment

by:dkim18
ID: 22619591
Thanks.
It came to me after I saw this....hhh.!!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question