以下是代码:
IF(selected_item_id IS NOT NULL AND selected_category IS NOT NULL) THEN
IF(selected_item_id <> "all") THEN
SELECT i.id, i.name, i.summary, i.description, i.location, c.name AS 'category_name' FROM items i, categories c WHERE i.category_id = c.id AND i.id LIKE selected_item_id;
ELSE IF(selected_item_id = "all" AND selected_category <> "all" AND selected_category in (SELECT name FROM categories)) THEN
SELECT i.id, i.name, i.summary, i.description, i.location, c.name AS 'category_name' FROM items i, categories c WHERE i.category_id = c.id AND c.name LIKE selected_category;
ELSE IF(selected_item_id = "all" AND selected_category = "all") THEN
SELECT i.id, i.name, i.summary, i.description, i.location, c.name AS 'category_name' FROM items i, categories c WHERE i.category_id = c.id;
END IF
END IF
当我尝试保存它时,我得到:
MySQL说:#1064在第17行'END IF'附近(这是最后一个END IF)
非常感谢帮助。