mysql-error-1241

Is it possible for a subquery to return two values?

限于喜欢 提交于 2019-12-01 16:28:41
问题 Is it possible for a subquery to return two values onto the outer query? Such as: SELECT 1, (SELECT COUNT(*), MAX(*) FROM test_table WHERE test=123) FROM another_table Or is there a better way to do this? 回答1: If you use the subquery in the FROM clause rather than the field list, then you can treat the output as a table and refer to the separate columns. 回答2: You are just selecting numbers as results so couldn't you just do: SELECT 1, COUNT(*), MAX(*) FROM test_table WHERE test=123 回答3: Not

MySQL Error “Operand should contain 1 column” [duplicate]

岁酱吖の 提交于 2019-11-29 06:37:17
This question already has an answer here: Operand Should Contain 1 Column - MySQL NOT IN 2 answers I could find a lot of similar questions but no real solution for my problem. My SQL query: UPDATE ADRESSEN SET EMAIL = 0 WHERE ID = (SELECT ID, COUNT(ID) AS COUNTER FROM EIGENSCHAFTEN WHERE Kategorie = "BOUNCE" GROUP BY ID HAVING COUNTER = 1) The error code I receive is #1241 - Operand should contain 1 column(s) If I just use the query in the parentheses it works and the result is ID | COUNTER 0002159 | 1 Where is my error? Thanks a lot for your help. The issue is your inner query is returning

mysql trigger operand should contain 2 columns

岁酱吖の 提交于 2019-11-28 14:29:01
My trigger looks like this: begin IF ((NEW.tgebucht >= NEW.tteilnmax) AND (NEW.tgebucht!=0) AND (OLD.tstatus=0)) THEN SET NEW.tstatus = 1; ELSEIF ((NEW.tgebucht < NEW.tteilnmax) AND (OLD.tstatus=1)) THEN SET NEW.tstatus =0; END IF; IF ((0,25*NEW.tteilnmax)>=(NEW.tteilnmax-NEW.tgebucht)) THEN SET NEW.trestplatze =1; END IF; end And I am getting an error like this: Operand should contain 2 column(s) I am not really sure why, I know it is related to second if but I can't configure where, does anyone has an idea what to change? Am I doing something wrong here? Any help would be appreciated. The

MySQL error 1241: Operand should contain 1 column(s)

試著忘記壹切 提交于 2019-11-27 08:48:34
I am trying to Insert data from a table1 into table2 insert into table2(Name,Subject,student_id,result) select (Name,Subject,student_id,result) from table1; Key for table2 is student_id. Assume that there are not any duplicates. I get the error: MySQL error 1241: Operand should contain 1 column(s) There are only four columns in table2. Syntax error, remove the ( ) from select . insert into table2 (name, subject, student_id, result) select name, subject, student_id, result from table1; Just remove the ( and the ) on your SELECT statement: insert into table2 (Name, Subject, student_id, result)

mysql trigger operand should contain 2 columns

空扰寡人 提交于 2019-11-27 08:45:02
问题 My trigger looks like this: begin IF ((NEW.tgebucht >= NEW.tteilnmax) AND (NEW.tgebucht!=0) AND (OLD.tstatus=0)) THEN SET NEW.tstatus = 1; ELSEIF ((NEW.tgebucht < NEW.tteilnmax) AND (OLD.tstatus=1)) THEN SET NEW.tstatus =0; END IF; IF ((0,25*NEW.tteilnmax)>=(NEW.tteilnmax-NEW.tgebucht)) THEN SET NEW.trestplatze =1; END IF; end And I am getting an error like this: Operand should contain 2 column(s) I am not really sure why, I know it is related to second if but I can't configure where, does

MySQL error 1241: Operand should contain 1 column(s)

巧了我就是萌 提交于 2019-11-26 14:18:28
问题 I am trying to Insert data from a table1 into table2 insert into table2(Name,Subject,student_id,result) select (Name,Subject,student_id,result) from table1; Key for table2 is student_id. Assume that there are not any duplicates. I get the error: MySQL error 1241: Operand should contain 1 column(s) There are only four columns in table2. 回答1: Syntax error, remove the ( ) from select . insert into table2 (name, subject, student_id, result) select name, subject, student_id, result from table1;

MySQL Syntax error message “Operand should contain 1 column(s)”

孤街醉人 提交于 2019-11-26 09:02:26
I tried running the following statement: INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT (a.number, b.ID, b.DENOMINATION) FROM temp_cheques a, BOOK b WHERE a.number BETWEEN b.START_NUMBER AND b.START_NUMBER+b.UNITS-1; which, as I understand it, should insert into VOUCHER each record from temp_cheques with the ID and DENOMINATION fields corresponding to entries in the BOOK table (temp_cheques comes from a database backup, which I'm trying to recreate in a different format). However, when I run it, I get an error: Error: Operand should contain 1 column(s) SQLState: 21000

MySQL Syntax error message “Operand should contain 1 column(s)”

假装没事ソ 提交于 2019-11-26 03:27:07
问题 I tried running the following statement: INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT (a.number, b.ID, b.DENOMINATION) FROM temp_cheques a, BOOK b WHERE a.number BETWEEN b.START_NUMBER AND b.START_NUMBER+b.UNITS-1; which, as I understand it, should insert into VOUCHER each record from temp_cheques with the ID and DENOMINATION fields corresponding to entries in the BOOK table (temp_cheques comes from a database backup, which I\'m trying to recreate in a different format).

Operand Should Contain 1 Column - MySQL NOT IN

Deadly 提交于 2019-11-26 02:16:33
SELECT * from campaigns WHERE id not in (SELECT e.id_campaign, d.name, d.frequency, d.country, d.referral, d.bid, d.status, COUNT(e.id) AS countcap FROM campaigns d LEFT JOIN served e ON d.id = e.id_campaign WHERE d.status = 'Active' GROUP BY e.id_campaign HAVING countcap < d.frequency) I get the error "Operand Should Contain 1 Column" - but I need the COUNT(e.id) There's always this: select * from campaigns where id not in ( select id_campaign from ( select e.id_campaign as id_campaign, d.frequency, e.id from campaigns d left join served e on d.id = e.id_campaign where d.status = 'Active'

Operand Should Contain 1 Column - MySQL NOT IN

自闭症网瘾萝莉.ら 提交于 2019-11-26 01:50:02
问题 SELECT * from campaigns WHERE id not in (SELECT e.id_campaign, d.name, d.frequency, d.country, d.referral, d.bid, d.status, COUNT(e.id) AS countcap FROM campaigns d LEFT JOIN served e ON d.id = e.id_campaign WHERE d.status = \'Active\' GROUP BY e.id_campaign HAVING countcap < d.frequency) I get the error \"Operand Should Contain 1 Column\" - but I need the COUNT(e.id) 回答1: There's always this: select * from campaigns where id not in ( select id_campaign from ( select e.id_campaign as id