'SQL in Access - Use LIKE to find a value from a column in another column
I used access, i have two columns in T1 :
| col1 | col2 | col3 |
|---|---|---|
| AA | AA-rtz | 1234 |
| AB | AA-rtz | 1239 |
I want to get with sql access all registers in T1 where col1 is a string from col2, also :
| col1 | col2 | col3 |
|---|---|---|
| AA | AA-rtz | 1234 |
| AA-rtz | 1239 |
I use :
Select * from T1 where col1 like col2 + '*'
Whats wrong?
Thank you very much
Solution 1:[1]
Try this code:
Select * from T1 where LEFT(col2,2) = col1
This assumes your data is as shown above. You can modify the LEFT function's second argument to suit your situation otherwise - (At the moment it looks at the first 2 characters from the left).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick |
