Jump to content

Simple SQL Syntax Problem: Help?


DasaniBoy

Recommended Posts

Hi there,

 

I am having issues with my code, was hoping you could help.  I'm writing a query for access, and I can't get the code below to work.  I know it's a stupid syntax issue, so could someone please tell me what I'm doing wrong?  I'm trying to use an inner join because B constantly changes, but I still want the dates to transfer to A, even when the entry is removed from B. 

 

update A.Covered=1, A.Date=B.Date 

WHERE SELECT B.ID from B INNER JOIN A as A_1 ON A_1.ID=B.ID WHERE A_1.Covered==0;

 

This is what I was trying to do:

ID's in A is searched in B.

If ID is in B, then copy date field from B into A’s Date field.  Also, Covered field would go to 1.

If ID is NOT in B, then don’t copy anything and remain blank; covered would also go to 0. 

Issue: B constantly adds and deletes entries, so in A if there is an ID that had a date entry, and B deletes that ID entry, then in A the covered field would go to 0, signifying it was dropped from B, while the date remains, signifying that it was there at one point, but not anymore.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.