473,395 Members | 1,443 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.

Nested statements using Update

13
I am using the following statement to replace address abbreviations. I would like to expand this to look at multiple abbreviations which would be replace with the same word (ex: ST, ST., STR would all be replace with STREET). Right now I have indivisual statements for each abbreviation.

Expand|Select|Wrap|Line Numbers
  1. UPDATE Address SET Address.PHYSICAL_ADDRESS = Replace([PHYSICAL_ADDRESS]," ST "," STREET ")
  2. WHERE (((Address.[PHYSICAL_ADDRESS]) Like "* ST*"));
Apr 24 '12 #1
10 2002
Rabbit
12,516 Expert Mod 8TB
You just need to nest your replace functions in each other.
Expand|Select|Wrap|Line Numbers
  1. Replace(Replace(someString, abbrev1, replace1), abbrev2, replace2)
Apr 24 '12 #2
Rose427
13
Should I also nest the Where statement?
Apr 24 '12 #3
Rabbit
12,516 Expert Mod 8TB
You can't nest a where statement; it's not a function. Use an OR to combine the two filters.
Expand|Select|Wrap|Line Numbers
  1. WHERE 1 OR 2
Apr 24 '12 #4
Rose427
13
I updated the query to:

Expand|Select|Wrap|Line Numbers
  1. UPDATE Addresses SET Addresses.PHYSICAL_ADDRESS = Replace(Replace([PHYSICAL_ADDRESS], " DR", " DRIVE"), " DRV", " DRIVE")
  2. WHERE ((Addresses.[Physical_Address] Like "* DR*" or  Like  "* DRV*"));
I am getting a Syntax error on the "Where" statement saying that I am missing an operator. I thought "Like" was the operator.
Apr 25 '12 #5
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

You're correct, Like is an operator. That means you need to give it two operands. You only have one operand in the second like.
Expand|Select|Wrap|Line Numbers
  1. Addresses.[Physical_Address] Like "* DR*" or Addresses.[Physical_Address] Like "* DRV*"
On a side note, I'm not sure you want to replace " st" because "123 stanton st" becomes "123 streetanton street". The same applies to your dr.
Apr 25 '12 #6
Rose427
13
Thank you, it is working now. I agree with you regarding " ST" and " DR". Not sure how I am going to handle that yet. It would be easy if I could guarantee that there was a space after, but I know there 8 times out of 10 there is not.
Apr 25 '12 #7
Rabbit
12,516 Expert Mod 8TB
Well if there's no space after it, what's after it? A period I assume. Just use two replacements, one for " st " and one for " st. "
Apr 25 '12 #8
Rose427
13
The "st" is usually at the end of the line so it it not followed by any characters.
May 2 '12 #9
Rose427
13
There are also many street names that start with ST, like St Mary Ave or even St John St without a period at the end of either. Do you think the use of "Last" would be useful in this situation?
May 2 '12 #10
Rabbit
12,516 Expert Mod 8TB
If it's not followed by anything, you can append a space to the end yourself. There's not much you can do about st mary st unless you were willing to learn and use regular expressions. I don't know what you mean by last, I'm not aware of any such function. If you mean replace just the last occurrence, you could do that.
May 2 '12 #11

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

Similar topics

5
by: Jimmy Tran | last post by:
Hello, I am doing a bmw tracking project for school using asp and access2000. on my search.asp page, I can search for a particular bmw and order it if i want. It works fine when i do select query...
0
by: Chris Hall | last post by:
The records in my database are displayed in a form as follows: %> <form action="report-ammend1.42.asp" method="post"name="form"> <table border=1> <% x = 1
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
4
by: Profetas | last post by:
Hi, Nested statements helps to generate complex source code, what is the nesting limit that you normally consider? I know that the Halsted and McCabe analyses can define the acceptable level,...
4
by: solidsna2 | last post by:
Hi, I am relatively new to SQL. I am using SQL 2000. I am trying to Update a field base in a criteria in a scond table. UPDATE Tbl1 SET Tbl1.Row2 = '1' WHERE Tbl1.Row1...
5
by: cover | last post by:
I have an input form that passes data when submitted to a second form to let the user know what they have just entered into the db. My question comes with using 'update'. I'd like to query the...
1
by: arthy | last post by:
Hi, Is it possible to execute multiple statements on to the database using a single dbconnection object.what is the drawback in using .If not possible ,then how can the execution of multiple...
1
by: nanoman | last post by:
Hello, I've got a Nested Set structure in MySQL 4 here with - id - lft - rgt - parent_id - root_id I wrote some test scripts and i discovered that the Nested Set (the
10
by: Chris H | last post by:
Greetings, I'm trying to update an address field with "standard" abbreviations so that I can do a comparison of various accounts to one another on the address. I can update a set of records for...
3
by: matthewaveryusa | last post by:
Hi, This is a simple question. How do I get statements that are nested (so like an if statement inside an if statement) to have the little +/- button so I can collapse it? thanks, Matt
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.