INSERT AND UPDATE mySQL

I need to insert into one table and update another… Appreciate that this is rather a general question but…IS it best to run two separate queries, run a query for the INSERT and use a trigger to do the update or is it better to try and do all in a single query (if that’s at all possible)… Is there a rule of thumb or any best practices be be observed here?

Thanks in advance

I don’t think it is possible to do this in a single query. Even if it were your code would be a LOT clearer to do the job in 2 queries.

No, it’s not possible to do it in one query. You have to have separate queries. And @Gandalf is right, even if you could, that would get VERY confusing - SQL is powerful, but keeping things to a single purpose is usually a better idea.

    @gandalf458 @DaveMaxwell thanks for swift and clear responses.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.