Jump to content

What does this error mean?


EchoFool

Recommended Posts

Hey,

 

I just got a mysql query error but no idea what it means ... my query is:

 

mysql_query("UPDATE user_data SET Proposal = 0 WHERE Proposal NOT IN (SELECT UserID FROM user_data)") or die(mysql_error());

 

Yet its not happy with it as i get this error:

You can't specify target table 'user_data' for update in FROM clause

 

The idea is if your proposal has the id of a user that is no longer in the database then set proposal to 0.

 

=/

Link to comment
Share on other sites

Yes, although if kickstart's method doesn't work, you can probably work around the issue using a temp table.  The best way is to use engine=memory. 

 

create table t_orphans engine=memory as SELECT Proposal FROM user_data WHERE Proposal NOT IN (Select distinct UserID FROM user_data);
update user_data u, t_orphans t set Proposal = 0 WHERE u.Proposal = t.Proposal;
drop table t_orphans;

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.