2015-04-16 38 views
0

我得到的錯誤信息:{}的MySQL錯誤#1054 SQL似乎罰款(觸發)

#1054 - 未知列在 'where子句'

'kaseamgc_store.plans.plan_id'此消息來自我的觸發器,它是插入觸發器之前的觸發器。它運行的SQL語句:

UPDATE kaseamgc_store.store_players 
    SET credits = credits + kaseamgc_store.plans.creditvalue 
WHERE kaseamgc_store.plans.plan_id = kaseamgc_store.orders.plan_id 
    AND kaseamgc_store.store_players.authid LIKE '%kaseamgc_store.orders.steam_id' 

現在我跑到下面的SQL時,我得到的消息(可能無關):

INSERT INTO finish_order (txn_id, payer_email, mc_gross, steam_id, username, 
          password, date, provider, plan_id, forum_userid) 
    VALUES ('info', 'email-adress', '1.00', 'STEAM_ID', 'TheUsername', 
      'no-pass', 20150416, 'paypal', 1, 0) 

我已刪除了一些信息,但它是不相關的。總之這裏的列plans.plan_id看起來像在phpMyAdmin一些截圖:

enter image description here

我有4行,所以我應該有1-4 plans.plan_id

編輯:所以,我似乎有這個問題到處都是。我知道這與線條有關,但不知道爲什麼會發生。這是我想要比較兩個*變量的地方。有什麼想法嗎?

+0

很難判斷你是否有問題,或者你是否解決了問題。此外,您只需標記那些相關的DBMS。你正在使用SQL Server或MySQL?它們不是同一件事。 –

+0

將觸發器的完整代碼添加到問題中。 –

+0

@SeanLange我還沒有解決它,對不起,我不清楚。使用mysql服務器,並不知道它們不一樣。 – 3rdaccountQQ

回答

0

您正在更新表kaseamgc_store.store_players並期望表kaseamgc_store.plansplan_id)的一列。

UPDATE kaseamgc_store.store_players -- table store_players 
    SET ... 
WHERE kaseamgc_store.plans.plan_id .... -- table plans 

這是行不通的。正確的解決方案取決於你確切需要的東西。先前的局部變量賦值可能是一個解決方案。