Operand Should Contain 1 Column - MySQL Not In

Error: Operand should contain 1 column(s)

Try an update self join:

UPDATE History h1
INNER JOIN
(
SELECT home_id, MAX(id) AS max_id
FROM History
GROUP BY home_id
) h2
ON h1.home_id = h2.home_id AND
h1.id = h2.max_id
SET
h1.status = 0;

This assumes that you want to zero out the status of every record per home_id group having the max id value.

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

You can't specify multiple patterns like that.

You'll need to use separate not like predicates and OR them:

select filmId,
titel,
genre
from films
inner join genres on films.genreId = genres.genreId
where (
titel not like '%blood%'
or titel not like '%kill%'
)
and genre in ('thriller', 'griezel')

Or perhaps you meant to use AND to check the title doesn't contain both blood and kill

select filmId,
titel,
genre
from films
inner join genres on films.genreId = genres.genreId
where (
titel not like '%blood%'
and titel not like '%kill%'
)
and genre in ('thriller', 'griezel')

Operand Should Contain 1 Column - MySQL NOT IN

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'
group by e.id_campaign
having count(e.id) < d.frequency
)
)

MySQL: Error: Operand should contain 1 column(s). What's wrong with my use of WHERE...NOT IN(SELECT...)?

You are close. But NOT IN does work that way -- because the subquery returns multiple columns. And you are comparing to only one value. Instead, use two separate comparisons:

SELECT activity
FROM a
WHERE n <> (SELECT MAX(n) FROM a) AND
n <> (SELECT MIN(n) FROM a) ;

Operand should contain 1 column error in mysql

I am guessing that you want three rows in the second subquery. The expression (2, 3, 4) is causing the error.

INSERT IGNORE INTO thread_user(thread_id,user_id,last_read_date)
SELECT 24, 1, NOW()
UNION ALL
SELECT 24, b.a, NOW()
FROM (SELECT 2 as a UNION ALL
SELECT 3 UNION ALL
SELECT 4
) b;

This is just a guess on your intentions. Note that the outer UNION can be UNION ALL -- you should always use the latter unless you want to incur the overhead of removing duplicates.

MySQL - Operand should contain 1 column(s)

Your subquery is selecting two columns, while you are using it to project one column (as part of the outer SELECT clause). You can only select one column from such a query in this context.

Consider joining to the users table instead; this will give you more flexibility when selecting what columns you want from users.

SELECT
topics.id,
topics.name,
topics.post_count,
topics.view_count,
COUNT( posts.solved_post ) AS solved_post,
users.username AS posted_by,
users.id AS posted_by_id

FROM topics

LEFT OUTER JOIN posts ON posts.topic_id = topics.id
LEFT OUTER JOIN users ON users.id = posts.posted_by

WHERE topics.cat_id = :cat
GROUP BY topics.id

Why does operand should contain 1 column(s) error appear when I don't use a subquery?

Join properly with ON and remove the parentheses around GROUP BY

SELECT COMPANY.COMPANY_CODE, 
COUNT(LEAD_MANAGER.LEAD_MANAGER_CODE),
COMPANY.FOUNDER
FROM COMPANY
INNER JOIN LEAD_MANAGER ON COMPANY.COMPANY_CODE = LEAD_MANAGER.COMPANY_CODE
GROUP BY COMPANY.COMPANY_CODE,
COMPANY.FOUNDER


Related Topics



Leave a reply



Submit