Jump to content

Recommended Posts

No, you can't have the criteria for updating one table be dependant soley on another. The criteria has to be checking a field in the table you are updating. For example:

"UPDATE stats year SET text='hello' WHERE stats.tid = (SELECT tid FROM year WHERE year = 2007 LIMIT 1)";

 

You only don't need (single) quotes for numerical date. I assume 2007 is in your database as a number, if it is a string it DOES need the quotes.

 

This query updates the field 'text' where the id is the same id as the one in the year table that has a year of 2007. Of course, this has to be limited to one to do it this way. If you wanted to update ALL text fields that matched that year, you would need to use a join, or something.

Link to comment
https://forums.phpfreaks.com/topic/68732-update-in-php/#findComment-345520
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.