I get an error near WHERE
clause on executing this query.
update AssetData set EmployeeName = ISNULL(EmployeeName,'') [email protected]
where ([AssetNumber] like'%" + WA_number.Text + "%')
and ID IN (SELECT ID FROM AssetData ORDER BY ID DESC
where ([AssetNumber] like'%" + WA_number.Text + "%') LIMIT 1)
Someone please help me to figure out what is wrong with this?
Best How To :
and ID IN (SELECT ID FROM AssetData ORDER BY ID DESC
where ([AssetNumber] like'%" + WA_number.Text + "%') LIMIT 1)
The where
should become before ORDER BY
. Although legal, in ( ... limit 1)
doesn't make sense because in
should be used with a list. I recommend using = max(ID)
instead
and ID = (SELECT max(ID) FROM AssetData where [AssetNumber] like'%" + WA_number.Text + "%')
you could leave out the first part of your where clause since the ID matches the same criteria already
update AssetData set EmployeeName = ISNULL(EmployeeName,'') [email protected]
where ID = (SELECT max(ID) FROM AssetData where [AssetNumber] like'%" + WA_number.Text + "%');