有关程序中mysql嵌套查询的任何建议吗?
CREATE DEFINER=`root`@`%` PROCEDURE `GET_PLACE_PARENT_CATEGORY`(IN paramCategoryId INT)
BEGIN
SELECT pc.place_parent_category_id, (SELECT pcc.place_category FROM place_category pcc WHERE pcc.place_category_id = pc.place_parent_category_id )
FROM place_category pc WHERE pc.place_category_id = paramCategoryId;
END
答案 0 :(得分:0)
您的嵌套查询位于同一个表中。你确定这是对的吗? 我相信你想在2个表之间进行简单的连接。这样的事情可能是:
SELECT pc.place_parent_category_id,pcc.place_category
来自place_category pc
在pcc.place_category_id = pc.place_parent_category_id上将la连接place_parent_category作为pcc
在哪里pc.place_parent_category_id = paramCategoryId;