Search code examples
mysqlsqlinner-join

How to resolve operand should contain 1 column(s) for inner join?


I'm new MySQL. When I was executing the following query I'm getting operand should contain 1 column(s) error.

select a.status, a.order_number, a.net_order_amt, a.retailer_id, a.order_date
from (select status, order_number, net_order_amt, retailer_id, 
        (order_date/1000,'%Y-%m-%d') as order_date 
      from Order
      where FROM_UNIXTIME(order_date/1000,'%Y-%m-%d') between '2019-08-31' and '2019-08-31'
     ) as a 
INNER JOIN Retailer AS r on a.retailer_id = r.retailer_id;

I'm a novice programmer in MySql and I'm unable to solve the error. Can someone help me to resolve the issue.


Solution

  • You're not using the from_unixtime funtion in the select that causes this

    select a.status, a.order_number, a.net_order_amt, a.retailer_id, a.order_date
    from (select status, order_number, net_order_amt, retailer_id, 
            FROM_UNIXTIME(order_date/1000,'%Y-%m-%d') as order_date 
          from Order
          where FROM_UNIXTIME(order_date/1000,'%Y-%m-%d') between '2019-08-31' and '2019-08-31'
         ) as a 
    INNER JOIN Retailer AS r on a.retailer_id = r.retailer_id;
    

    Use the function that will solve the error.