logo
Tags down

shadow

MS Access SQL Issue with OR AND Operators


By : khalid nawaz
Date : May 06 2020, 07:28 AM

I have query at the bottom is to update the FullComplDate field if the below requirements are satisfied. I am not sure if it is an issue with the arrangement of the statements or parenthesis but I've tried changing the order of the statements and adding parenthesis but no luck.

BOTH of these statements are true:

  1. tblSubscribers.FullComplDate Is Null
  2. tblSubscribers.SubscrComplDate Is Not Null

AND either one of these two statements are true:

  1. tblSubscribers.CoverageLevel="Employee Only"))
  2. tblSubscribers.CoverageLevel="Employee + Child(ren)"

what is happening is that any record that satisfies that first three statements is being updated AND any record the satisfies just the 4th statement is being updated.

UPDATE tblSubscribers SET tblSubscribers.FullComplDate = Format(Date(),"mmmm" & " " & "yyyy")
WHERE (((tblSubscribers.FullComplDate) Is Null) AND ((tblSubscribers.SubscrComplDate) Is Not Null) AND (((tblSubscribers.CoverageLevel)="Employee Only")) OR (((tblSubscribers.CoverageLevel)="Employee + Child(ren)")));
Answer :

the issues is with the parenthesis.... if you recude them and only have them wrapping the OR condition it should work better.

UPDATE tblSubscribers SET tblSubscribers.FullComplDate = Format(Date(),"mmmm" & " " & "yyyy")
WHERE tblSubscribers.FullComplDate Is Null
AND tblSubscribers.SubscrComplDate Is Not Null
AND (tblSubscribers.CoverageLevel="Employee Only" OR tblSubscribers.CoverageLevel ="Employee + Child(ren)")

You could try the IN Clause to avoid the OR

UPDATE tblSubscribers SET tblSubscribers.FullComplDate = Format(Date(),"mmmm" & " " & "yyyy")
WHERE tblSubscribers.FullComplDate Is Null
AND tblSubscribers.SubscrComplDate Is Not Null
AND tblSubscribers.CoverageLevel IN ("Employee Only" ,"Employee + Child(ren)")


Share : facebook icon twitter icon
Related Posts Related Posts :
  • clear array after form submit
  • pass url variable to javascript
  • access data using api
  • div position fixed css
  • add horizontal line between two div
  • disable toggle button css
  • css fixed line height
  • background image not working
  • table cell border
  • text line break css
  • overlay div on div
  • text direction rtl css
  • javascript convert string to an object
  • bind inner div click to outer div
  • jquery ajax oncomplete
  • how to use promise in for loop
  • jquery get element using variable
  • javascript send textbox value
  • pass div class content to another class or id
  • css new line after element
  • css calc not working properly
  • link disabled jquery
  • sql join table to subquery
  • set textarea value using php
  • php merge two arrays into one
  • php form with google captcha
  • update current row in php
  • php date format mysql
  • mysql pdo select query
  • php function return an array
  • PHP mysqldump database to sql file
  • display image query
  • php create array using foreach loop
  • associative array php
  • group_concat in mysql laravel
  • php array_push empty
  • mysql on update cascade not working
  • pdo insert prepared statement
  • mysql insert ignore vs on duplicate key
  • mysql insert into existing row
  • mysql multi insert query
  • mysql group by show all rows
  • php change profile image
  • combine multiple arrays into one array php
  • how to sum values in an array
  • how to get sum of the total time
  • How to Create Facebook live stream without notification using API ?
  • on button click make div visible
  • css affect another element on hover
  • insert line after paragraph word
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org