Hey all i im getting this error when trying to update a table in my database:
Every derived table must have its own alias
Here is my mysql query i am trying to update with:
UPDATE (SELECT clientinfo.idNumber, clientinfo.theCompName, clientoffers.idNumber,
clientoffers.expTimeWaiting, clientoffers.theDateStart,
clientoffers.theDateEnd, clientoffers.theOffer, clientoffers.isActive,
clientoffers.theType, clientoffers.fixedAmount, clientoffers.fixedUsed
FROM clientinfo, clientoffers
WHERE clientoffers.idNumber = clientinfo.idNumber
AND clientoffers.theDateEnd >= '2010-06-03'
AND clientoffers.theDateStart <= '2010-06-03'
AND clientoffers.idNumber = 'NB351560'
AND clientoffers.isActive = 'YES')
SET clientoffers.fixedUsed = clientoffers.fixedUsed + 1
That seems OK but doesn't seem to work for some reason?
Any help would be great! :o)
UPDATE
sqltemp = "UPDATE clientinfo, clientoffers SET clientoffers.fixedUsed = clientoffers.fixedUsed + 1 WHERE clientoffers.idNumber = clientinfo.idNumber" & _
"AND clientoffers.theDateEnd >= '2010-06-03'" & _
"AND clientoffers.theDateStart <= '2010-06-03'" & _
"AND clientoffers.idNumber = 'NB351560'" & _
"AND clientoffers.isActive = 'YES'"
oRecordset.Open sqltemp, oConnection,3,3
It gives me the error of ODBC driver does not support the requested properties.
I'm using Mysql 5.1 with classic ASP.
David
Why is there a select there? is that even necessary?
Why not:
UPDATE clientinfo, clientoffers
SET clientoffers.fixedUsed = clientoffers.fixedUsed + 1
WHERE clientoffers.idNumber = clientinfo.idNumber
AND clientoffers.theDateEnd >= '2010-06-03'
AND clientoffers.theDateStart <= '2010-06-03'
AND clientoffers.idNumber = 'NB351560'
AND clientoffers.isActive = 'YES'
or even further, if there is a foreign-key-constraint on the two tables for idNumber
(or you can assume every clientoffer
entry always has a corresponding clientinfo
entry):
UPDATE clientoffers
SET clientoffers.fixedUsed = clientoffers.fixedUsed + 1
WHERE clientoffers.theDateEnd >= '2010-06-03'
AND clientoffers.theDateStart <= '2010-06-03'
AND clientoffers.idNumber = 'NB351560'
AND clientoffers.isActive = 'YES'