Advertise with us

mysql SET and UPDATE

Hi Expert!

I'm trying to replace a column value based off values from other columns, but I keep getting syntax errors. What am I doing wrong? Here's what I've tired:

SELECT * FROM `table` WHERE `id_1` =164 and `id_2` = 6
SET `id_1` = (188|164)
WHERE `id_1` = 164 AND `id_2` = 6 
UPDATE `table`

This gives me a syntax near SET.

SELECT * FROM `table` WHERE `id_1` = 164 AND `id_2` = 6
UPDATE `table`
SET `id_1` = 188
WHERE `id_2` = 6

This gives me an error for everything below UPDATE.

Help? Thanks.
Last updated:7/9/2013 4:42:27 AM

2 Answers

AVADHESH PATEL
AVADHESH PATEL

Hi,



You cann't use the UPDATE and SELECT both within a one query.

Execute the both query separately like this:

SELECT * FROM `table` WHERE `id_1` = 164 AND `id_2` = 6
And then execute:

UPDATE `table`
SET `id_1` = 188
WHERE `id_2` = 6;

Cast Broady
Cast Broady

mysql SET and UPDATE

if you  want fill Picture field you can use update

UPDATE PictureProduct 

SET Picture = 

      (SELECT * FROM OPENROWSET(BULK N'C:\1.jpg', SINGLE_BLOB) AS image)

WHERE Id = 6

Answer