2 回答
TA贡献1998条经验 获得超6个赞
您可以使用if条件选择值,如下所示:
SELECT IF(day = 'Monday', 'TRUE','FALSE') as dayResult, IF(date = '2018-10-15', 'TRUE','FALSE') as dateResult,
IF(time = '19:45:34', 'TRUE','FALSE') as timeResult, IF(title = 'NEW-BOTTLE', 'TRUE','FALSE') as titleResult FROM `table`
它将返回要么1或0根据条件满足。希望它以任何方式帮助你。
TA贡献1155条经验 获得超0个赞
您可以使用 switch 语句打印详细摘要。这是伪代码。
switch (true) {
case 0:
SELECT Count(id) FROM `table`
WHERE day = 'Monday' and date = '2018-10-15' and time = '19:45:34' and title = 'NEW-BOTTLE'
// Get the count from query
if ($count != '0') {
// Criteria met successfully, not need to check other cases;
break;
}
case 1:
SELECT Count(id) FROM `table`
WHERE day = 'Monday' and date = '2018-10-15' and time = '19:45:34'
//get the count
if ($count != '0')
echo "Title is incorrect";
case 2:
SELECT Count(id) FROM `table`
WHERE day = 'Monday' and date = '2018-10-15' and title = 'NEW-BOTTLE'
//get the count
if ($count != '0')
echo "Time didn't match";
case 3:
SELECT Count(id) FROM `table`
WHERE day = 'Monday' and time = '19:45:34' and title = 'NEW-BOTTLE'
if ($count != '0')
echo "Date didn't match";
case 4:
SELECT Count(id) FROM `table`
WHERE date = '2018-10-15' and time = '19:45:34' and title = 'NEW-BOTTLE'
if ($count != '0')
echo "Day didn't match";
}
- 2 回答
- 0 关注
- 148 浏览
添加回答
举报