Update field (multiple criteria and updates)

I would like to update 2 fields with the following
Where [item description] like "*BASIC*" update [item description] = "BASIC" 
and [item] = "HITS"
Where [item description] like "*FARE*" update [item description] = "FARE" 
and [item] = "HITS"
Where [item description] like "*SEARCH*" update [item description] = 
"SEARCH" and [item] = "HITS"

I typically use design view to set up queries and I can only do one of the 
three changes in this view.  Is there are way to write this in sql to do all 
three updates at the same time?

This is the sql query based on my entry in design view for the first update.
"UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = "BASIC", 
[Q-CHARGES].ITEM = "HITS"
WHERE ((([Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"));"
0
Utf
1/8/2010 5:19:01 PM
access.queries 6343 articles. 1 followers. Follow

5 Replies
2277 Views

Similar Articles

[PageSpeed] 43

You can use a nested IIF statement when updating Item Description.
UPDATE [Q-CHARGES]
SET [Q-CHARGES].[ITEM DESCRIPTION] =
   IIF([ITEM DESCRIPTION]) Like "*basic*","BASIC",
   IIF([ITEM DESCRIPTION]) Like "*Fare*","FARE",
   IIF([ITEM DESCRIPTION]) Like "*Search*","SEARCH",
   [ITEM DESCRIPTION])))
, [Q-CHARGES].ITEM = "HITS"
WHERE [Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"
OR [Q-CHARGES].[ITEM DESCRIPTION]) Like "*Fare*"
OR [Q-CHARGES].[ITEM DESCRIPTION]) Like "*Search*"


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

ksh wrote:
> I would like to update 2 fields with the following
> Where [item description] like "*BASIC*" update [item description] = "BASIC" 
> and [item] = "HITS"
> Where [item description] like "*FARE*" update [item description] = "FARE" 
> and [item] = "HITS"
> Where [item description] like "*SEARCH*" update [item description] = 
> "SEARCH" and [item] = "HITS"
> 
> I typically use design view to set up queries and I can only do one of the 
> three changes in this view.  Is there are way to write this in sql to do all 
> three updates at the same time?
> 
> This is the sql query based on my entry in design view for the first update.
> "UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = "BASIC", 
> [Q-CHARGES].ITEM = "HITS"
> WHERE ((([Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"));"
0
John
1/8/2010 6:04:56 PM
BACKUP DATABASE        BACKUP DATABASE            BACKUP DATABASE
Try this --
UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = 
IIF(([Q-CHARGES].[ITEM DESCRIPTION] Like "*basic*", "BASIC", 
IIF([Q-CHARGES].[ITEM DESCRIPTION] Like "*FARE*", "FARE", 
IIF([Q-CHARGES].[ITEM DESCRIPTION] Like "*SEARCH*", "SEARCH", 
[Q-CHARGES].[ITEM DESCRIPTION]))) 
WHERE  [Q-CHARGES].ITEM = "HITS";

-- 
Build a little, test a little.


"ksh" wrote:

> I would like to update 2 fields with the following
> Where [item description] like "*BASIC*" update [item description] = "BASIC" 
> and [item] = "HITS"
> Where [item description] like "*FARE*" update [item description] = "FARE" 
> and [item] = "HITS"
> Where [item description] like "*SEARCH*" update [item description] = 
> "SEARCH" and [item] = "HITS"
> 
> I typically use design view to set up queries and I can only do one of the 
> three changes in this view.  Is there are way to write this in sql to do all 
> three updates at the same time?
> 
> This is the sql query based on my entry in design view for the first update.
> "UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = "BASIC", 
> [Q-CHARGES].ITEM = "HITS"
> WHERE ((([Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"));"
0
Utf
1/8/2010 6:19:01 PM
Thank you both!  The second solution worked since it also updated the item 
field based on the basic fare and search criteria.  What I was doing in three 
separate queries I can now do in 1.  This forum is the best learning tool I 
know of, thank you again.

"John Spencer" wrote:

> You can use a nested IIF statement when updating Item Description.
> UPDATE [Q-CHARGES]
> SET [Q-CHARGES].[ITEM DESCRIPTION] =
>    IIF([ITEM DESCRIPTION]) Like "*basic*","BASIC",
>    IIF([ITEM DESCRIPTION]) Like "*Fare*","FARE",
>    IIF([ITEM DESCRIPTION]) Like "*Search*","SEARCH",
>    [ITEM DESCRIPTION])))
> , [Q-CHARGES].ITEM = "HITS"
> WHERE [Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"
> OR [Q-CHARGES].[ITEM DESCRIPTION]) Like "*Fare*"
> OR [Q-CHARGES].[ITEM DESCRIPTION]) Like "*Search*"
> 
> 
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
> 
> ksh wrote:
> > I would like to update 2 fields with the following
> > Where [item description] like "*BASIC*" update [item description] = "BASIC" 
> > and [item] = "HITS"
> > Where [item description] like "*FARE*" update [item description] = "FARE" 
> > and [item] = "HITS"
> > Where [item description] like "*SEARCH*" update [item description] = 
> > "SEARCH" and [item] = "HITS"
> > 
> > I typically use design view to set up queries and I can only do one of the 
> > three changes in this view.  Is there are way to write this in sql to do all 
> > three updates at the same time?
> > 
> > This is the sql query based on my entry in design view for the first update.
> > "UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = "BASIC", 
> > [Q-CHARGES].ITEM = "HITS"
> > WHERE ((([Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"));"
> .
> 
0
Utf
1/8/2010 8:03:02 PM
On Fri, 8 Jan 2010 09:19:01 -0800, ksh <ksh@discussions.microsoft.com> wrote:

>I would like to update 2 fields with the following
>Where [item description] like "*BASIC*" update [item description] = "BASIC" 
>and [item] = "HITS"
>Where [item description] like "*FARE*" update [item description] = "FARE" 
>and [item] = "HITS"
>Where [item description] like "*SEARCH*" update [item description] = 
>"SEARCH" and [item] = "HITS"
>
>I typically use design view to set up queries and I can only do one of the 
>three changes in this view.  Is there are way to write this in sql to do all 
>three updates at the same time?
>
>This is the sql query based on my entry in design view for the first update.
>"UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = "BASIC", 
>[Q-CHARGES].ITEM = "HITS"
>WHERE ((([Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"));"

Just be careful, and as Karl says, *back up*: think about what will happen if
the item description were to contain "Whitsunday" or "unsearchable" or "this
is basically the same as Item 123".

-- 

             John W. Vinson [MVP]
0
John
1/8/2010 8:10:49 PM

"John W. Vinson" wrote:

> On Fri, 8 Jan 2010 09:19:01 -0800, ksh <ksh@discussions.microsoft.com> wrote:
> 
> >I would like to update 2 fields with the following
> >Where [item description] like "*BASIC*" update [item description] = "BASIC" 
> >and [item] = "HITS"
> >Where [item description] like "*FARE*" update [item description] = "FARE" 
> >and [item] = "HITS"
> >Where [item description] like "*SEARCH*" update [item description] = 
> >"SEARCH" and [item] = "HITS"
> >
> >I typically use design view to set up queries and I can only do one of the 
> >three changes in this view.  Is there are way to write this in sql to do all 
> >three updates at the same time?
> >
> >This is the sql query based on my entry in design view for the first update.
> >"UPDATE [Q-CHARGES] SET [Q-CHARGES].[ITEM DESCRIPTION] = "BASIC", 
> >[Q-CHARGES].ITEM = "HITS"
> >WHERE ((([Q-CHARGES].[ITEM DESCRIPTION]) Like "*basic*"));"
> 
> Just be careful, and as Karl says, *back up*: think about what will happen if
> the item description were to contain "Whitsunday" or "unsearchable" or "this
> is basically the same as Item 123".
> 
> -- 
> 
>              John W. Vinson [MVP]

Thank you for the excellent advice.  I used a linked table from another db 
to create a new table so I wouldn't change the original data and I regularly 
back up both databases.
0
Utf
1/11/2010 1:16:02 PM
Reply:

Similar Artilces:

updating sheets based on data in first sheet
Another payroll question, I have a workbook that contains 26 sheets, one for each bi-weekl payroll period. I would like to set it up so when i add a new employe the rest of the sheets also update automatically with that employee name and information. I have been able to acheive this to a limited degree using th =sheet1!a1 formula, but this only updates the info in the first cel and particularly the first column. I would like to acheive this using the first sheet, since at th end of the year I would like to be able to calculate ytd figure easily. Thank -- Message posted from http://www.Exc...

Update for MS Money 2005?
I have Money 2005. Is there an update to MS Money for Canadian users? Thanks in advance for any answers. We need a bit more information! Are you having problems with M2005 or is this just a post-Christmas/New Year random query when you are trying to get away from the in-laws? -- Regards Bob Peel, Microsoft MVP - Money For unofficial FAQs see http://money.mvps.org/ or http://umpmfaq.info/ I do not respond to any emails that I have not specifically asked for. "Daniel" <Daniel@discussions.microsoft.com> wrote in message news:E86EAB89-21DE-4505-ACAD-647278D736BD@microso...

how to run multiple macro's at once
Hello, I have 350 separate macro's, how do I get them to run in successive order, other then having to click on each individually? Is there a way to 'link' them all together? Thanks, Roxane You can write a macro that in turn calls the other macros. E.g., Sub RunThemAll() Macro1 Macro2 '... End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Roxane" <Roxane@discussions.microsoft.com> wrote in message news:44732365-A840-4C5D-9025-D4B90AEEB887@microsoft.com... > Hello, > > ...

Problem with Script Updating
I am using a script to update the “1099 Type” field for Master Vendor table. The script basically is a basic if-then statement. This script is run “Before Document Commit” and it’s not updating correctly, its flip-flopping the results. When the script is set to run Before Document Commit I have the “Destination mapping” field “1099 Type” set to “Use Script”. Script below: If SourceFields("Send 1099") = "N" Then DestinationFields("Options.1099 Type").Value = 1 Else DestinationFields("Options.1099 Type").Value = 4 End If I have also tried this s...

Multiple reply templates
I am trying to create multiple templates to be used to reply to differing e-mails. I created my first template and then used my rules setup to automatically use it to reply to a received e-mail. I then thought that I created three additional templates for three other rules, but when I try to set up the rules, the new templates do not show up. Anyone have an idea why this might be happening? Where did you save the template files? Or are these "have server reply" rules? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrato...

PivotTable page field list- limiting what a user sees
Folks, I am creating an automotive Winter & All Season Tire listing. What I would like to provide from a pivottable is, from 3 page field items a user picks; 1) Type (Winter or All Season) 2) Rim size (13,14,15,16,17 or 18 inch) 3) a list of only those tires which meet the above What I am getting now from the drop dwon lists is; 1) Type works fine 2) shows 13,14,15,16,17,18 and then repeats 13,14,15,16,17,18 3) shows all tires sizes (which is above 30 items long instead of about 4-5) Any thoughts on how this might be done with VB etc. ...

Multiple date select calender
I need a calender for MFC in which i can select multiple dates similar to what is there in calender of outlook 2003. Also I need the functionality to be able to select the days i.e. sunday, monday, etc. Is there some activex available freely which i can use. Or is it possible to achieve the same by subclassing the existing CMonthCalCtrl in MFC. Please guide me. Thanks in Anticipation Software Engineer wrote: > I need a calender for MFC in which i can select multiple dates similar to > what is there in calender of outlook 2003. Also I need the functionality to > be able to sel...

Microsoft Update only updates Windows Defender
iacrosoft Update only updates Windows Defender - I have to use Belarc Advisor to get a list of missing updates, and then go to the Microsoft Download Center to search for the missing updates and download and install them one at a time. I have Windows XP Home SP3, with Microsoft Update set to automatic download - can anyone tell me why I do not get all the necessary upadtes? Is this a sudden, new problem? When was Automatic Updates last working? Can you update manually via http://windowsupdate.microsoft.com? Any chance you've got a beta build of WinXP SP3 installed? What...

Publisher 2007 and Microsoft Updates
I created a newsletter yesterday - everything fine - use Publisher all the time. Then an automatic update came down this morning and I can't open the file - it says "Publisher cannot open file" Other documents in Publisher are opening - any ideas? http://support.microsoft.com/kb/972566/ -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Kim" <Kim@discussions.microsoft.com> wrote in message news:8754339B-99DC-4D09-83AD-6B34D8215274@microsoft.com... >I created a newsletter yesterday - everythin...

Copy and Paste based on criteria
When Department changes I need to insert the ADDRESS below the Account-Institution Business Office:. Another option I have is that if address = get new address from page 2. HELP xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ending 02/13/10 Account-Institution Business Office: DEPT EMP.NBR EMPLOYEE NAME ADDRESS 883 27903 ROBERSON, JOE abc 883 119245 MUSIL, TODD E abc 883 Total ----------------------------------------------------------------- Account-Institution Business Office: DEPT EMP.NBR EMPLOYEE NAME ADDRES...

Update question
Soory if this is the wrong place to ask this, but cannot find a NG proper to Windows 7. I currently run Windows Vista and am getting tired of Vista's decision to tell me that it is going to shut down in less than a minute. So have decided to upgrade to Windows &. I note that I can purchase an upgrade versiom for 64 quid from Amazon or an apparently full version of Windows 7 Home premium for 89 quid. My question is this - If I buy the upgrade version will I only be able to load it on a new PC in the future if I already have windows Vista installed? i.e For any future cl...

Outlook 2003 died mysteriously after update
Setup in a nutshell... System: Lenovo T500 laptop OS: Vista Business SP1 32-bit Software: Office Outlook 2003 SP3 Problem... So I'm using this setup for over a year, everything OK. Yesterday I did two things and now Outlook dies (quietly, sans error message) immediately after startup. It show the splash screen, displays my inbox, and *poof* disappears. What I did earlier... 1. Windows Update installed: KB9766662, KB979306, KB979099, KB975929 2. At the same time, while searching for another program to uninstall I stumbled upon (and uninstalled) Windows LIVE Toolbar and...

Adding two fields together
Does anyone have a solution how can I manage the following: Basic setup: Custom entity with many nvarchar attributes. I created a custom view and selected a filter and the fields I want to have. (I need to export those to Excel-sheet) The problem is that lets say I have attributes A and B, which are ofcourse shown as different fields in the view. What I want is to have them in the same cell in Excel (when I do export) and not in two different columns. Is there any easy way to achieve this without touching the entity itself? (or do I have to create a custom attribute C and some java script On...

How update entity in post update?
I created a handler for Update post callout for Opportunity. I want update some fields of the opportunity on the PostUpdate. However, if I call the Update method of CRMOpportunity in the PostUpdate I will create a recursive post callout. Can somebody help me? Thank you for pay attention []'s Vin�cius Pitta Lima de Ara�jo You need to check the OrigObjectXML field to see what fields were updated and then act appropriately. Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On Wed, 4 Aug 2004 17:43:17 -0300, "Vin�cius ...

Cannot install update KB979906 for .NET Framework 1.1 SP1
Running : Windows XP media center edition SP3 Have tried installing KB979906 a few times and also downloaded update manually but cannot install this update. Receiving error 0x643.Is it safe to uninstall the .NET Framework 1.1 and re-install as possibly corrupt , without having to uninstall/re-install all other .NET frameworks 2 , 3 and 3.5 including the updates that go with them? .. Hello sherlockomes, you might want to look at the following kb article to see if this will help with the error 80070643. <http://windows.microsoft.com/en-US/windows-vista/Windows-Update-error...

Print record once, update Yes/No field verifiying print
I would like to print a group of records, then have a Yes/No field [Printed] updated in my Jobs table with an update query showing the records were printed. Then next time the report runs, In my query criteria I will test for True values on the Yes/No field. Then only the records with the Yes/No field marked No will print. Any suggestions? Thanks Tommyboy,there's more to this question than meets the eye. For an explanation of what's involved, see: Has the record been printed? at: http://allenbrowne.com/ser-72.html The article includes a free sample database that dem...

latest update too MSCFV2
Hi, I have MSCFV2 version 6.5.7825.0. Could someone inform me if this is the latest download? Looks like you have 6.5.7825.0 from 05/21/2006, but there is a newer version - 6.5.7831.0 from 06/01/2006. C. Smith Enso Technologies, Incorporated http://www.ensotech.com On Tue, 13 Jun 2006 04:25:02 -0700, Paul <Paul@discussions.microsoft.com> wrote: >Hi, > >I have MSCFV2 version 6.5.7825.0. Could someone inform me if this is the >latest download? Christopher Smith csmith@ensotech.com Enso Technologies, Incorporated http://www.ensotech.com Also - meant to post this in t...

Dynamic Menu update
Hi All, I need to update a menu item dynamically, setting its SetCheck property to either true or false, based on a user operation. I am trying to do this from a custom function. Usually, the pCmdUI pointer is used. But how do I do it from another function? Thanks Your "other function" should change some setting. In your ON_UPDATE_COMMAND_UI handler, you should check that setting and call SetCheck as needed. -------------- Ajay Kalra ajaykalra@yahoo.com In addition to Ajay's response, this page may help you: http://msdn2.microsoft.com/en-us/library/6kc4d8f...

multiple account mail duplication
I have set up 2 accounts in Windows Live Mail. Irrespective of which account incoming mail is addressed to, it gets duplicated into the other account. How do I fix it that incoming messages only hit the email account to which they are addressed without this duplication? Thanks!!!!! -- Edmund Do both accounts use the same password? It sounds like one account is an alias of the other account. -- Ron Sommer MS MVP- Windows Live Mail "Edmund" <Edmund@discussions.microsoft.com> wrote in message news:7F19664C-5A95-44B6-B945-7FB773E2F517@microsoft.com... > I h...

online updates for money2003(not updating)
Money gets its updates from spcomstock.com and the server has moved to a new site. The default site that money provides has to be changed. At this time I don't know how to do this. If I find out how to do this I will Post it. ...

how do you count cells with a time criteria??
I need to get a count of cells in a column based off of a time criteria. The colum is a in "TIME" format ( 8:00 AM, 12:00 PM, etc). I need to get a count of cells that are between 8:00 AM and 12 PM . . what formula would I use?? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ Hi ..., =countif(A2:A20,">=08:00")-countif(A2:A20,">12:00") if you want it under row 20 you can use A21: =countif(A$2:OFFSET(A21,-1,0),">=08:0...

Printing Multiple Workbooks through Master Document?
Word has a facility to pull together multiple documents into one "master" document. I have 120 separate workbooks that need to be grouped and printed in specific orders. Unfortunately that order changes monthly. In order to print easily does Excel have master document capabilities or would a macro openening and closing specific files from an input source be better? I've tried linking and inserting the print ranges into a workbook but this has not worked. Suggestions? Hi ScottP33 If you want to have control of the order you can fill in the names of the workbooks from a d...

Multiple Pivot Tables?
Am I able to have two different pivot tables in the same worksheet? What I am doing is I made a timesheet and we have one pivot table that counts up the Service Type and sums the Time. I now want a separate pivot table that will give me the Job Number and the total time associated with that particular job. I can't seem to figure this out. Any help is greatly appreciated. THANK YOU! ...

Payroll Update
HI all, We are running GP 7.5. I installed SP7 and the July 2005 tax update for CDN payroll. Now out payroll administrator gets an error message: 'The modified version of P_Payroll registry is missing'. How do I fix this problem Thanks -- Henry ...

[ANN] Excel X security update
Hi All, A security update for Excel X was also released today: http://www.microsoft.com/mac/downloads.aspx?pid=download&location=/mac/d ownload/officex/ExcelX_Security_1017.xml&secid=5&ssid=17&flgnosysreq=Tru e Or at least: http://www.microsoft.com/mac/downloads.aspx Corentin -- --- Mac:MS MVP (Francophone) --- http://www.mvps.org - http://mvp.support.microsoft.com MVPs are not MS employees - Les MVP ne travaillent pas pour MS Remove "NoSpam" to e-mail me - Retirez "NoSpam" pour m'�crire ...