last day (14 days later) » 

3:41 PM
1
Q: UPDATE three table in one single UPDATE query

Eric_phI have three tables like this: 1/ topics table: topic_id category_id subject 1 1 first 2 3 second 3 2 third 2/ categories table: category_id cat_name 1 art 2 math The topics table is...

 
I presume this is MySQL? The update-join syntax differs between RDBMS.
Though the m/dd/yyyy date format suggests maybe MS SQL Server (and if it is mysql, that should be made into a proper datetime type rather than a varchar type)
 
@MichaelBerkowski: Yes, you are correct!. This my MySQL.
@MichaelBerkowski: Yes. And I will correct it. I would use date datetime NOT NULL, .Can you help with the UPDATE query, please?
 
Do I understand correctly that you are accessing both $_POST vals and $_GET['tid'] in the same HTTP request so all are known at the time you want to do the update?
 
@the_pete: I already read the link you provided. However, this is the very first time I've encountered this UPDATE syntax level. So, a full answer will be very much appreciated!
@MichaelBerkowski: Yes, I do. I can do the GET and POST to perform the name=value pair for my edit.php?tid=1, for example. My problem is the UPDATE query.
 
@Eric_ph Another question - in your sample, you have two articles with the same topic_id. Is the new $_POST['body'] intended to update both of them?
 
3:41 PM
@MichaelBerkowski: No, please focus on the airticle_id #1 only because the airticle_id# 2 is the topic's reply, which may belong to another user who replied to the topic.
 
@Eric_ph Does anything in the $_POST identify that article? If not, it increases the complexity of this significantly (to retrieve the first article grouped by topic_id)
@Eric_ph I have just a couple of minutes -
 
Yes, the $_POST['tid'] is from the FORM SUBMISSION. The $_GET['tid'] comes form a view_topic.php page
 
But what about article_id? How is it known which article to target when there are many with the same topic_id?
 
SO, you can assume that the tid is all about a certain topic_id for editing/updating only.
 
...which article.body to update, that is... what criterion identifies the specific article? First per topic?
 
3:47 PM
yes, you are right
 
@Eric_ph Right about what- first per topic?
 
if the certain topic_id# is repeated in the articles table, you can assume that the second on is associated with the reply
second one
 
@Eric_ph Ok - that complicates things a little but I'll formulate an answer.
 
Thannks so much
 
@Eric_ph Ok - it's poste.d
 
3:56 PM
ok. let me take a look at it. Thanks for your fast answer!
 

last day (14 days later) »