2017-08-02 36 views
-1

工作如何存儲在圖像1可變MySQL的選擇情況下不得使用功能

BEGIN 
DECLARE image1 VARCHAR(250); 
select case when (
      (
       select COUNT(*) 
       from profile_images 
       where building_id = bid 
        and contractor_id = cid 
       ) > 0 
      ) then (
       select distinct (image) 
       into image1 
       from profile_images 
       where building_id = bid 
        and contractor_id = cid limit 1 
       ) else (
      select distinct (image) 
      into image1 
      from profile_images 
      where contractor_id = cid limit 1 
      ) 

END 
RETURN image1; 
END 

回答

1

嘗試值:

BEGIN 
DECLARE image1 VARCHAR(250); 
select case when 
      (
       select COUNT(*) 
       from profile_images 
       where building_id = bid 
        and contractor_id = cid 
       ) > 0 
       then (
       select distinct (image) 
       -- into image1 
       from profile_images 
       where building_id = bid 
        and contractor_id = cid limit 1 
       ) else (
      select distinct (image) 
      -- into image1 
      from profile_images 
      where contractor_id = cid limit 1 
      ) 
END into image1; 
RETURN image1; 
END 
+0

答案是有用 –

+0

其根據本地服務器,但主服務器的工作有消息ishows錯誤「 #2014 - 命令不同步;現在無法運行此命令「@wchiquito –

+0

@samjadps:檢查[B.5.2.14命令不同步](https://dev.mysql.com/doc/refman/ 5.7/EN /命令-外的sync.html)。 – wchiquito

相關問題