473,700 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested statements using Update

13 New Member
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 2023
Rabbit
12,516 Recognized Expert Moderator MVP
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 New Member
Should I also nest the Where statement?
Apr 24 '12 #3
Rabbit
12,516 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
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 New Member
The "st" is usually at the end of the line so it it not followed by any characters.
May 2 '12 #9
Rose427
13 New Member
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

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

Similar topics

5
3516
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 to get data. But when I try to order a bmw(using update query), it gives me this message error: Error Type: Microsoft JET Database Engine (0x80004005) Operation must use an updateable query. /bmw/search.asp, line 257
0
2400
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
945
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 datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
4
1993
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, but in your personnel point of views what is the limit before you re-code the block into multiple blocks a 3 level nesting example
4
1916
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 = (SELECT Tbl1.Row1 FROM Tbl2, Tbl1
5
2196
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 database by equipment number (equipno is unique) and query all fields from that row, populating an original form 'look alike' whereby the user can add detail to the original records as the db builds. I'm using 'date' twice because I'd like to...
1
2496
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 statements using a single object be done. thanks in advance, arthy
1
9709
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
3566
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 "Road" to "Rd", but when I tried to stack the update clauses, I seem to get random updates within the file. All the updates are correct, but they're incomplete. Not sure how this needs to be done, I added a TOP statement but that didn't work. ...
3
1436
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
8731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4408
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4660
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2032
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.