Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

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
Avatar of rknevitt
rknevitt

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

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers