0

Here is my code that I have and I cannot figure out why the following code returns the error Operand should contain 1 column(s). I know that both queries work independantly of the query I have below. ANy help would be appreciated

SELECT * 
FROM 2014_summary, 2014_profiles 
WHERE 2014_summary.player_id = 2014_profiles.player_id AND tournament_id = 'bec904c4-b2a3-4eba-a2bc-335aca680a40' AND 2014_summary.player_id 
NOT IN
(SELECT 
    T1.*, 
    T2.player_id as primary_player_id 
FROM (SELECT id, lead_id, form_id, MAX(case when field_number = 1 then value end) display_name, 
    MAX(case when field_number = 7 then value end) email, 
    MAX(case when field_number = 6 then value end) tournament_name, 
    MAX(case when field_number = 3 then value end) primary_golfer, 
    MAX(case when field_number = 4 then value end) backup_golfer, 
    MAX(case when field_number = 5 then value end) date, 
    MAX(case when field_number = 8 then value end) tournament_id 
FROM `wp_rg_lead_detail` 
GROUP BY lead_id)T1 
INNER JOIN (SELECT CONCAT(first_name, ' ', last_name) as player_name, player_id FROM 2014_profiles)T2 ON T1.primary_golfer = T2.player_name
WHERE display_name = "Hosker" AND tournament_id != 'bec904c4-b2a3-4eba-a2bc-335aca680a40')
ORDER BY (last_name) ASC
4

1 回答 1

0

not in的是:

2014_summary.player_id NOT IN
    (SELECT  T1.*, T2.player_id as primary_player_id 

MySQL 不知道在selectplayer_id. 所以它返回一个错误。实际上,这是 ANSI 标准的 SQL 功能,所有数据库都以这种方式工作。an 中的子查询in只需要返回一列。

我想你想要:

2014_summary.player_id NOT IN
    (SELECT TT2.player_id
     . . .
于 2014-02-02T18:11:48.800 回答