Home > Mobile >  Syntax issue with UPDATE query using WHERE and LIKE
Syntax issue with UPDATE query using WHERE and LIKE

Time:09-28

I am trying to update an empty field in my table to show "Spray Guns Service Kit" if the product code field has "ASPASK" in it.

This is what I have tried thus far:

UPDATE Products
SET field7 = 'Spray Gun Service Kit'
WHERE ProductCode LIKE '%ASPASK%' ;

Access keeps telling me I am updating 0 rows when I should be updating 100s. However, when I change the code to it works but only with one product:

UPDATE Products
SET field7 = 'Spray Gun Service Kit'
WHERE ProductCode = 'ASPASK001' ;

I haven't used Access or SQL since 2015 so I am a tad out of touch with the syntax so I'm certain the issue is with how I am using the LIKE statement

CodePudding user response:

MS-Access uses * instead of the % wildcard character:

UPDATE Products
SET field7 = 'Spray Gun Service Kit'
WHERE ProductCode LIKE '*ASPASK*' ;
  • Related