开发者

Using the AND operating with an SQL COUNT() query

开发者 https://www.devze.com 2023-04-03 11:37 出处:网络
Is it possible to use the AND operator in an SQL COUNT() query? For example: SELECT COUNT(field1) AS count FROM table WHERE field1=\'value1\' AND field2=value2\'

Is it possible to use the AND operator in an SQL COUNT() query? For example:

SELECT COUNT(field1) AS count FROM table WHERE field1='value1' AND field2=value2'

Right now I'm getting a synt开发者_如何学运维ax error with that query. Any advice?


Yes:

SELECT COUNT(*) AS count
FROM table 
WHERE field1='value1' 
AND field2='value2'; -- btw, you were missing the leading quote from value2


You'll get a syntax error because you've left out a quote mark before value2.


I would take a look at the word "Read", seems to be reserved.

0

精彩评论

暂无评论...
验证码 换一张
取 消