Jump to content

See results of update query before executing it


mds1256

Recommended Posts

Hi

 

I think im going crazy! a while back i'm sure i remember reading that you could run a 'select update' query so you could see what the results would look like before actually running the query. I cannot rember how to do it so could you please point me in the right direction :)

Link to comment
Share on other sites

Hi

 

I think im going crazy! a while back i'm sure i remember reading that you could run a 'select update' query so you could see what the results would look like before actually running the query. I cannot rember how to do it so could you please point me in the right direction :)

 

As far as I know, this is not possible. You may have mixed up SELECT UPDATE with UPDATE ... SELECT, which does something completely different.

 

UPDATE `users` SET `avatar` = (SELECT `defaults`.`avatar` FROM `defaults` WHERE `id`='1')

 

This would look for the column avatar on the table 'defaults' where the ID column is 1, and put the value of the 'avatar' column into every user on the 'users' table to the value from the defaults table.

Link to comment
Share on other sites

Hey

 

Thanks, think I may have been confused.

 

I found what i was trying to do e.g.

 

If i wanted to update a field's data within a table and replace part of a piece of data but see what it would look like first i would do the following before running an update script:

 

select replace(location, 'UK', 'London') from table

 

this would show me what the table would look like after the query has ran, then once im happy i can run the update script.

 

Thanks for the comments

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.