-1

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.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Seenu69
  • 1,041
  • 2
  • 15
  • 33
  • 1
    Possible duplicate of [MySQL - Operand should contain 1 column(s)](https://stackoverflow.com/questions/14046838/mysql-operand-should-contain-1-columns) – Jens Sep 05 '19 at 11:01
  • 2
    `(order_date/1000,'%Y-%m-%d')` - what are you trying to do here. You forgot to use the function in this. – Madhur Bhaiya Sep 05 '19 at 11:01

2 Answers2

2

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.

Ashok Gadri
  • 520
  • 4
  • 11
0
     ..... (order_date/1000,'%Y-%m-%d') as 
    order_date.....

This part of ypur query is causing that error add a function name to it like to_date (order_date/1000,'%Y-%m-%d') or as i see in your where clause FROM_UNIXTIME(order_date/1000,'%Y-%m-%d')

Himanshu
  • 3,830
  • 2
  • 10
  • 29