troubleshooting Question

#1241 - Operand should contain 1 column MySQL error

Avatar of rknevitt
rknevitt asked on
MySQL Server
3 Comments1 Solution2447 ViewsLast Modified:
HI, Im getting the following error when i run the below MySQL code

#1241 - Operand should contain 1 column(s)

The code causing problems is this, i basically want to get the field 'plate' where the stock.regdate falls between regyear.startdate and regyear.enddate

(SELECT regyear.plate, regyear.startdate, regyear.enddate FROM regyear WHERE 'stock.regdate' between regyear.startdate and regyear.enddate) as RegYear

When i remove the code from the rest of the query, run it on its own, substituting stock.regdate for '2004-09-02' it works perfectly.

What might i be doing wrong?

Cheers
Rob
SELECT
stock.id,
stock.registration,
stock.advertisedprice,
stock.datein,
stock.variant,
stock.mileage,
stock.exteriorname,
stock.interiorname,
stock.ispoa,
stock.ismoa,
stock.supplierid,
stock.statusid,
stock.typeid,
stock.buyerid,
stock.datepurchase,
stock.vin,
stock.enginenumber,
stock.buyprice,
stock.specification,
stock.regdate,
stock.datetaxexpire,
stock.datemotexpire,
stock.bodytypeid,
stock.fuelid,
stock.transmissionid,
stock.siteid,
stock.vatqualifying,
stock.owners,
stock.spec_leather,
stock.spec_metallic,
stock.spec_navigation,
stock.spec_bluetooth,
stock.spec_sunroof,
stock.spec_cd,
stock.spec_heatedseats,
stock.spec_xenons,
model.id,
model.makeid,
model.name,
make.id,
make.name,
exterior.id,
exterior.name,
interior.id,
interior.name,
status.name,
(SELECT DATEDIFF(CURRENT_DATE(),stock.datein)) as DaysInStock,
(SELECT regyear.plate, regyear.startdate, regyear.enddate FROM regyear WHERE 'stock.regdate' between regyear.startdate and regyear.enddate) as RegYear 
FROM
stock AS stock
INNER JOIN models AS model 
             ON model.id = stock.modelid
INNER JOIN makes AS make 
             ON make.id = model.makeid
LEFT JOIN exterior AS exterior 
             ON stock.exteriorid = exterior.id
LEFT JOIN interior AS interior
             ON stock.interiorid = interior.id
INNER JOIN status AS status
             ON stock.statusid = status.id
WHERE stock.id = 1
ASKER CERTIFIED SOLUTION
rknevitt

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros