MS Access SQL: in a query check if a field contains spaces and if it's equal to another field without them

StackOverflow https://stackoverflow.com/questions/22098167

質問

Is it possible to check if a table field contains spaces (one or multiple spaces) by using an MS-Access query? (if yes, how?)

I would to know if the A1 field of Table1 contains spaces and check if it without spaces is equal to field B1 of Table2 (without changing the tables data).

I've MS-Access 2007.

EDIT

Correct answer for MS-Access 2007:

SELECT DISTINCT your_table1.id FROM your_table1, your_table2 
WHERE A1 LIKE '* *' 
AND REPLACE(A1,' ','') IN (SELECT B1 FROM your_table2)
役に立ちましたか?

解決

You can use Replace in where clause to check spaceless version of A1

SELECT * FROM your_table 
WHERE A1 LIKE '% %' 
AND REPLACE(A1,' ','') IN (SELECT B1 FROM Table 2)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top