我想在 MySQL 查询中使用 if 语句来查询SELECT
数据库中的所有信息,如果它返回 true,或者返回COUNT
名为aid
.
伪代码:
IF (COUNT(`AID`) > 0) {
SELECT * FROM `a_votes` WHERE `aid` = '1'
} ELSE {
RETURN 'No Rows'
}
请你能告诉我我该怎么做吗?
编辑 - -
我尝试了以下查询,但收到错误消息Operand should contain 1 column(s)
SELECT IF( (
SELECT COUNT( aid ) AS `count`
FROM `a_votes`
WHERE `aid` =1 ) =0, 'true', (
SELECT *
FROM `a_votes`
WHERE `aid` =1
)
) AS message