Skip to content
Advertisement

Syntax issue with UPDATE query using WHERE and LIKE

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

Advertisement

Answer

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

UPDATE Products
SET field7 = 'Spray Gun Service Kit'
WHERE ProductCode LIKE '*ASPASK*' ;
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement