Chatar Singh
Chatar Singh

Reputation: 1063

What is meaning of double backslash(column_name\\(1)) in ms access database where clause?

I have some old code which has syntax like this.

SELECT * 
FROM Tb
WHERE (column_name\\(1)) mod 2 = 1

Can someone explain the statement column_name\\(1) in where clause.

Upvotes: 0

Views: 257

Answers (1)

Gustav
Gustav

Reputation: 55841

As is, it is invalid syntax. If it is a string in, say, C#, it may result in:

SELECT * 
FROM Tb
WHERE (column_name\(1)) mod 2 = 1

which can be reduced to:

SELECT * 
FROM Tb
WHERE column_name mod 2 = 1

*Test for Erik:*

The trick is, that Mod by itself does the integer rounding.

~~~vba
Public Sub TestMod()

    Dim Value   As Double
    Dim Index   As Integer
    
    For Index = 0 To 15
        Value = Index / 4
        Debug.Print Value, Value \ 1, Value Mod 2, (Value \ 1) Mod 2, Round(Value) Mod 2
    Next
    
End Sub

Output:

~~~vba
 0             0             0             0             0 
 0,25          0             0             0             0 
 0,5           0             0             0             0 
 0,75          1             1             1             1 
 1             1             1             1             1 
 1,25          1             1             1             1 
 1,5           2             0             0             0 
 1,75          2             0             0             0 
 2             2             0             0             0 
 2,25          2             0             0             0 
 2,5           2             0             0             0 
 2,75          3             1             1             1 
 3             3             1             1             1 
 3,25          3             1             1             1 
 3,5           4             0             0             0 
 3,75          4             0             0             0 

Upvotes: 1

Related Questions