Jump to content

Update in PHP


gple

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.