#1241: Operand should contain 1 column(s) [duplicate]










0
















This question already has an answer here:



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

    5 answers



I get the error code '#1241: Operand should contain 1 column(s)'.
The code worked once, I didn't alter it though. But now it doesn't work anymore.



What is the problem? It's something with the IN operator.



The code as below:



SELECT DISTINCT 
composition.compartikelnr,
composition.artikelnr,
aantal
FROM
webshops.composition
WHERE
composition.compartikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN
webshops.prodprice
ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
) AND
composition.artikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
)









share|improve this question















marked as duplicate by Madhur Bhaiya, Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 13:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • The sub-query should only return one column.

    – jarlh
    Nov 13 '18 at 13:20











  • My SQL isn't that good, how can I fix it?

    – M. Keller
    Nov 13 '18 at 13:24











  • I've reformatted your SQL; try not to write SQLs all on one line - it makes them hard to read, understand and reduces the likelihood that other people will want to help you

    – Caius Jard
    Nov 13 '18 at 13:27















0
















This question already has an answer here:



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

    5 answers



I get the error code '#1241: Operand should contain 1 column(s)'.
The code worked once, I didn't alter it though. But now it doesn't work anymore.



What is the problem? It's something with the IN operator.



The code as below:



SELECT DISTINCT 
composition.compartikelnr,
composition.artikelnr,
aantal
FROM
webshops.composition
WHERE
composition.compartikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN
webshops.prodprice
ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
) AND
composition.artikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
)









share|improve this question















marked as duplicate by Madhur Bhaiya, Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 13:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • The sub-query should only return one column.

    – jarlh
    Nov 13 '18 at 13:20











  • My SQL isn't that good, how can I fix it?

    – M. Keller
    Nov 13 '18 at 13:24











  • I've reformatted your SQL; try not to write SQLs all on one line - it makes them hard to read, understand and reduces the likelihood that other people will want to help you

    – Caius Jard
    Nov 13 '18 at 13:27













0












0








0









This question already has an answer here:



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

    5 answers



I get the error code '#1241: Operand should contain 1 column(s)'.
The code worked once, I didn't alter it though. But now it doesn't work anymore.



What is the problem? It's something with the IN operator.



The code as below:



SELECT DISTINCT 
composition.compartikelnr,
composition.artikelnr,
aantal
FROM
webshops.composition
WHERE
composition.compartikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN
webshops.prodprice
ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
) AND
composition.artikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
)









share|improve this question

















This question already has an answer here:



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

    5 answers



I get the error code '#1241: Operand should contain 1 column(s)'.
The code worked once, I didn't alter it though. But now it doesn't work anymore.



What is the problem? It's something with the IN operator.



The code as below:



SELECT DISTINCT 
composition.compartikelnr,
composition.artikelnr,
aantal
FROM
webshops.composition
WHERE
composition.compartikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN
webshops.prodprice
ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
) AND
composition.artikelnr IN (
SELECT
producten.artikelnr,
producten.merk,
producten.producttype,
producten.naam,
producten.hoeveelheid,
producten.eenheid,
producten.kleur,
prodprice.eurotoner,
producten.ean,
producten.seourl,
image.image,
producten.staat,
producten.huismerk,
producten.shopping
FROM
webshops.producten
LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
)




This question already has an answer here:



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

    5 answers







mysql sql mysql-error-1241






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 13:27









Caius Jard

10.7k21138




10.7k21138










asked Nov 13 '18 at 13:19









M. KellerM. Keller

1




1




marked as duplicate by Madhur Bhaiya, Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 13:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Madhur Bhaiya, Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 13:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • The sub-query should only return one column.

    – jarlh
    Nov 13 '18 at 13:20











  • My SQL isn't that good, how can I fix it?

    – M. Keller
    Nov 13 '18 at 13:24











  • I've reformatted your SQL; try not to write SQLs all on one line - it makes them hard to read, understand and reduces the likelihood that other people will want to help you

    – Caius Jard
    Nov 13 '18 at 13:27

















  • The sub-query should only return one column.

    – jarlh
    Nov 13 '18 at 13:20











  • My SQL isn't that good, how can I fix it?

    – M. Keller
    Nov 13 '18 at 13:24











  • I've reformatted your SQL; try not to write SQLs all on one line - it makes them hard to read, understand and reduces the likelihood that other people will want to help you

    – Caius Jard
    Nov 13 '18 at 13:27
















The sub-query should only return one column.

– jarlh
Nov 13 '18 at 13:20





The sub-query should only return one column.

– jarlh
Nov 13 '18 at 13:20













My SQL isn't that good, how can I fix it?

– M. Keller
Nov 13 '18 at 13:24





My SQL isn't that good, how can I fix it?

– M. Keller
Nov 13 '18 at 13:24













I've reformatted your SQL; try not to write SQLs all on one line - it makes them hard to read, understand and reduces the likelihood that other people will want to help you

– Caius Jard
Nov 13 '18 at 13:27





I've reformatted your SQL; try not to write SQLs all on one line - it makes them hard to read, understand and reduces the likelihood that other people will want to help you

– Caius Jard
Nov 13 '18 at 13:27












1 Answer
1






active

oldest

votes


















0














You have written IN( SELECT more,than,one,column,here FROM..)



IN requires you to select exactly one column from the subquery, so choose whichever column is related to what you're INning.



Perhaps this:



SELECT DISTINCT 
composition.compartikelnr,
composition.artikelnr,
aantal
FROM
webshops.composition
WHERE
composition.compartikelnr IN (
SELECT
producten.artikelnr
FROM
webshops.producten
LEFT JOIN
webshops.prodprice
ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
) AND
composition.artikelnr IN (
SELECT
producten.artikelnr
FROM
webshops.producten
LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
WHERE
image.image <> '' AND
producten.active = 1 AND
producten.ean <> '' AND
producten.shopping = 1
)


But I know nothing about your data structure, I just found columns that seemed to be related to artikelnr based on the name. I make no warranties that this code I've posted works, simply that it demonstrates what I mean by "select only one column in the SELECT query that is inside the IN brackets"




The code worked once, I didn't alter it though. But now it doesn't work anymore.




That is incredibly unlikely, I'm afraid.. At best the only explanation I have for that is that MySQL has some magical feature setting that allows you to select more than one column within an IN and it knows what to pick (or it blindly chooses the first column) and someone's altered the setting. If it does have such a setting, changing it to behave like other databases would be a good thing






share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You have written IN( SELECT more,than,one,column,here FROM..)



    IN requires you to select exactly one column from the subquery, so choose whichever column is related to what you're INning.



    Perhaps this:



    SELECT DISTINCT 
    composition.compartikelnr,
    composition.artikelnr,
    aantal
    FROM
    webshops.composition
    WHERE
    composition.compartikelnr IN (
    SELECT
    producten.artikelnr
    FROM
    webshops.producten
    LEFT JOIN
    webshops.prodprice
    ON producten.artikelnr = prodprice.artikelnr
    LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
    WHERE
    image.image <> '' AND
    producten.active = 1 AND
    producten.ean <> '' AND
    producten.shopping = 1
    ) AND
    composition.artikelnr IN (
    SELECT
    producten.artikelnr
    FROM
    webshops.producten
    LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
    LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
    WHERE
    image.image <> '' AND
    producten.active = 1 AND
    producten.ean <> '' AND
    producten.shopping = 1
    )


    But I know nothing about your data structure, I just found columns that seemed to be related to artikelnr based on the name. I make no warranties that this code I've posted works, simply that it demonstrates what I mean by "select only one column in the SELECT query that is inside the IN brackets"




    The code worked once, I didn't alter it though. But now it doesn't work anymore.




    That is incredibly unlikely, I'm afraid.. At best the only explanation I have for that is that MySQL has some magical feature setting that allows you to select more than one column within an IN and it knows what to pick (or it blindly chooses the first column) and someone's altered the setting. If it does have such a setting, changing it to behave like other databases would be a good thing






    share|improve this answer





























      0














      You have written IN( SELECT more,than,one,column,here FROM..)



      IN requires you to select exactly one column from the subquery, so choose whichever column is related to what you're INning.



      Perhaps this:



      SELECT DISTINCT 
      composition.compartikelnr,
      composition.artikelnr,
      aantal
      FROM
      webshops.composition
      WHERE
      composition.compartikelnr IN (
      SELECT
      producten.artikelnr
      FROM
      webshops.producten
      LEFT JOIN
      webshops.prodprice
      ON producten.artikelnr = prodprice.artikelnr
      LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
      WHERE
      image.image <> '' AND
      producten.active = 1 AND
      producten.ean <> '' AND
      producten.shopping = 1
      ) AND
      composition.artikelnr IN (
      SELECT
      producten.artikelnr
      FROM
      webshops.producten
      LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
      LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
      WHERE
      image.image <> '' AND
      producten.active = 1 AND
      producten.ean <> '' AND
      producten.shopping = 1
      )


      But I know nothing about your data structure, I just found columns that seemed to be related to artikelnr based on the name. I make no warranties that this code I've posted works, simply that it demonstrates what I mean by "select only one column in the SELECT query that is inside the IN brackets"




      The code worked once, I didn't alter it though. But now it doesn't work anymore.




      That is incredibly unlikely, I'm afraid.. At best the only explanation I have for that is that MySQL has some magical feature setting that allows you to select more than one column within an IN and it knows what to pick (or it blindly chooses the first column) and someone's altered the setting. If it does have such a setting, changing it to behave like other databases would be a good thing






      share|improve this answer



























        0












        0








        0







        You have written IN( SELECT more,than,one,column,here FROM..)



        IN requires you to select exactly one column from the subquery, so choose whichever column is related to what you're INning.



        Perhaps this:



        SELECT DISTINCT 
        composition.compartikelnr,
        composition.artikelnr,
        aantal
        FROM
        webshops.composition
        WHERE
        composition.compartikelnr IN (
        SELECT
        producten.artikelnr
        FROM
        webshops.producten
        LEFT JOIN
        webshops.prodprice
        ON producten.artikelnr = prodprice.artikelnr
        LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
        WHERE
        image.image <> '' AND
        producten.active = 1 AND
        producten.ean <> '' AND
        producten.shopping = 1
        ) AND
        composition.artikelnr IN (
        SELECT
        producten.artikelnr
        FROM
        webshops.producten
        LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
        LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
        WHERE
        image.image <> '' AND
        producten.active = 1 AND
        producten.ean <> '' AND
        producten.shopping = 1
        )


        But I know nothing about your data structure, I just found columns that seemed to be related to artikelnr based on the name. I make no warranties that this code I've posted works, simply that it demonstrates what I mean by "select only one column in the SELECT query that is inside the IN brackets"




        The code worked once, I didn't alter it though. But now it doesn't work anymore.




        That is incredibly unlikely, I'm afraid.. At best the only explanation I have for that is that MySQL has some magical feature setting that allows you to select more than one column within an IN and it knows what to pick (or it blindly chooses the first column) and someone's altered the setting. If it does have such a setting, changing it to behave like other databases would be a good thing






        share|improve this answer















        You have written IN( SELECT more,than,one,column,here FROM..)



        IN requires you to select exactly one column from the subquery, so choose whichever column is related to what you're INning.



        Perhaps this:



        SELECT DISTINCT 
        composition.compartikelnr,
        composition.artikelnr,
        aantal
        FROM
        webshops.composition
        WHERE
        composition.compartikelnr IN (
        SELECT
        producten.artikelnr
        FROM
        webshops.producten
        LEFT JOIN
        webshops.prodprice
        ON producten.artikelnr = prodprice.artikelnr
        LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
        WHERE
        image.image <> '' AND
        producten.active = 1 AND
        producten.ean <> '' AND
        producten.shopping = 1
        ) AND
        composition.artikelnr IN (
        SELECT
        producten.artikelnr
        FROM
        webshops.producten
        LEFT JOIN webshops.prodprice ON producten.artikelnr = prodprice.artikelnr
        LEFT JOIN (SELECT * FROM webshops.prodimage WHERE priority = 1) image ON producten.artikelnr = image.artikelnr
        WHERE
        image.image <> '' AND
        producten.active = 1 AND
        producten.ean <> '' AND
        producten.shopping = 1
        )


        But I know nothing about your data structure, I just found columns that seemed to be related to artikelnr based on the name. I make no warranties that this code I've posted works, simply that it demonstrates what I mean by "select only one column in the SELECT query that is inside the IN brackets"




        The code worked once, I didn't alter it though. But now it doesn't work anymore.




        That is incredibly unlikely, I'm afraid.. At best the only explanation I have for that is that MySQL has some magical feature setting that allows you to select more than one column within an IN and it knows what to pick (or it blindly chooses the first column) and someone's altered the setting. If it does have such a setting, changing it to behave like other databases would be a good thing







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 13:31

























        answered Nov 13 '18 at 13:25









        Caius JardCaius Jard

        10.7k21138




        10.7k21138













            Popular posts from this blog

            27

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            Category:Rhetoric