Weijing Lin Weijing Lin -4 years ago 92
MySQL Question

How can I use MySQL primary key as variable

I'm trying to update a column which contains primary key, such as image

Update goods
Set thumb_image = 'xxx/image/{$goods_id}.jpg'


how to make it?

Thank you,

Answer Source

You need to use concat for this:-

Update goods Set thumb_image = concat('xxx/image/', goods_id, '.jpg')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download