0

Let's say I've got 3 product description fields with the values AC-120 XXX, AC-120,CCC and AC-120 BBB.

How would I get that information from a table using only AC-120 as my search argument?

I've tried using the subStr function but that won't return any values either

    SELECT TbArtikel.Artikel_Merk, TbArtikel.Artikel_Groep, TbArtikel.Artikel_Categorie_ID, TussenMAATenARTKEL.VoorraadNummer, TbArtikel.Artikel_ID, TussenMAATenARTKEL.ArtikelDetail_ID, TbArtikel.Artikel_Prijs_Advies, TbArtikel.Artikel_Prijs_Bees, TbArtikel.Artikel_Omschrijving
FROM TbArtikel INNER JOIN TussenMAATenARTKEL ON TbArtikel.Artikel_ID = TussenMAATenARTKEL.Artikel_ID
WHERE (((TbArtikel.Artikel_Merk)="Yonex") AND  ((TbArtikel.Artikel_Omschrijving)="%AC-102%"));
2
  • 1
    "I've tried using the subStr function" Share your code please. Commented Sep 13, 2019 at 8:19
  • Use MID() function as SELECT MID(YourColumn, 1, 6) Commented Sep 13, 2019 at 8:24

3 Answers 3

1

LIKE is very appropriate for this comparison. However, MS Access uses different wildcards from standard SQL. So you want:

TbArtikel.Artikel_Omschrijving) LIKE "*AC-102*"

In standard SQL, this would be:

TbArtikel.Artikel_Omschrijving) LIKE "%AC-102%"
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this is exactly what I was looking for :)
1

Try '((TbArtikel.Artikel_Omschrijving) LIKE "%AC-102%"' instead of '((TbArtikel.Artikel_Omschrijving)="%AC-102%"'

4 Comments

What if 'AC-102' is in the end of the string?
w3schools.com/sql/sql_like.asp according to this site "%subString% Finds any values that have "subString" in any position"
Using LIKE "%AC-102%" did not work, it wouldn't display any information
This property has to be used on the where field, it should work, cause this is the way to do properly
0

Use MID() function as

MID(TbArtikel.Artikel_Omschrijving, 1, 6) = 'AC-120'

Instead of

TbArtikel.Artikel_Omschrijving ="%AC-102%"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.