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 關注
- 172 瀏覽
添加回答
舉報