开发者

Using the AND operating with an SQL COUNT() query

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜