Reputation: 97
I have the following command line written in c#, but I keep getting an exception telling me that there is incorrect syntax near ','. Any ideas?
SELECT Name, Age
FROM testTable
WHERE Name = 'Roger', Age BETWEEN '19' AND '21', Sex LIKE M%;
Any help is greatly appreciated. Thank you.
Upvotes: 0
Views: 78
Reputation: 16413
In SQL you must use AND
or OR
in the where clause:
In addition, you have 2 other syntax errors:
BETWEEN 19 AND 21
if the columns are numericLIKE
value needs quoting as it is a string LIKE 'M%'
The result should be this:
SELECT Name, Age FROM testTable WHERE Name = 'Roger' AND Age BETWEEN 19 AND 21 AND Sex LIKE 'M%';
Upvotes: 1
Reputation: 382274
You must use AND
, not a comma, to separate conditions in WHERE
:
SELECT Name, Age FROM testTable
WHERE Name = 'Roger' AND Age BETWEEN 19 AND 21 AND Sex LIKE 'M%';
Upvotes: 8