#1241 - Operand should contain 1 column(s) In wamp on phpmyadmin

问题: Nested query in Sql. SELECT *, (SELECT `supplier_sign_up_id`, ( SELECT email_address FROM supplier_s...

问题:

Nested query in Sql.

SELECT
   *,
   (SELECT `supplier_sign_up_id`,
         (
            SELECT
               email_address 
            FROM
               supplier_sign_up 
            WHERE
               supplier_sign_up_id = 42 LIMIT 1
         )
      FROM
         `suppliers_acc` 
      WHERE
         singup_login_id = 138 LIMIT 1
   )
FROM
   `singup_login` 
WHERE
   1;

It's give error-

Operand should contain 1 column(s).

How to resolve it.


回答1:

Try This,

SELECT *,
    (SELECT `supplier_sign_up_id` FROM suppliers_acc WHERE singup_login_id = 138 LIMIT 1) as supplier_sign_up_id ,
    (SELECT `email_address` FROM supplier_sign_up  WHERE supplier_sign_up_id = 42 LIMIT 1 ) as email_address
FROM
   `singup_login` 
WHERE
   1;

回答2:

Perhaps this does what you want:

SELECT sa.*,
       (SELECT ssu.email_address
        FROM supplier_sign_up ssu
        WHERE ssu.supplier_sign_up_id = 42
        LIMIT 1
       )
FROM suppliers_acc sa
WHERE sa.singup_login_id = 138;

I'm not sure why you are trying to return supplier_sign_up_id from the subquery. You know the value is 42. I suspect you just want email_address.

  • 发表于 2019-02-20 06:07
  • 阅读 ( 225 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除