Solved

Exact string match and replace in SQL??

Posted on 2008-10-01
3
2,155 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 350 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 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

690 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