简体   繁体   中英

MS Access 2010: SQL WHERE string LIKE field

A similar (not MS Access) question was posed and answered here. I have the same question within the context of an MS Access 2010 Application:

SQL WHERE string LIKE field

The following given solution is not applicable in MS Access as that application does not support CONCAT:

SELECT * FROM links 'subdomain.some-domain.com' LIKE %domain_name%"

My question - how in MS Access 2010 SQL may I specify "Include all records where String type field1 contains the substring given by String type field2?

The InStr function might be a viable alternative here:

SELECT *
FROM links
WHERE InStr(1, 'subdomain.some-domain.com', domain_column) > 0

This solution has the potential drawback that it would return true if domain_column were a substring of any portion of the input, but then again so would your LIKE option.

You can use like . The code in MS Access looks like:

SELECT *
FROM links
WHERE "subdomain.some-domain.com" LIKE "*" & domain_name & "*"

Of course, instr() is also very reasonable, unless your column contains other wildcards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM