2013-03-25 88 views
1
工作

我已經stored-proceduresSELECT三個數據庫列,但是當我把它作爲一個SELECT它不是的方式工作時,它把三種不同SELECT語句的工作它精細。多個SELECT語句中不經存儲過程在MySQL

工作查詢

 BEGIN 


      SET child = chid; 
      myloop: loop 
      IF x = loop_val THEN 
       LEAVE myloop; 
      END IF;  

      SELECT IFNULL(parent_pageid,0) into parent FROM page_content pc WHERE pc.pageid = child; 
      SELECT sef_url into sef_string FROM page_content pc WHERE pc.pageid = child;   

      SELECT menu_heading into menu_string FROM page_content pc WHERE pc.pageid = child; 


     END 

SELECT如下它不工作

SELECT IFNULL(parent_pageid,0) into parent, sef_url into sef_string, menu_heading into menu_string FROM page_content pc WHERE pc.pageid = child; 

有什麼不對的單SELECT報表?

感謝,

回答

1

你必須列出所有選定列,那麼所有的變量,就像這樣:

SELECT 
    IFNULL(parent_pageid,0), 
    sef_url, 
    menu_heading 
INTO 
    parent, 
    sef_string, 
    menu_string 
FROM page_content pc 
WHERE pc.pageid = child; 
相關問題