skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search