MySQL Insert into multiple tables? (Database normalization?)

前端 未结 8 2384
庸人自扰
庸人自扰 2020-11-22 01:56

I tried searching a way to insert information in multiple tables in the same query, but found out it\'s impossible? So I want to insert it by simpl

8条回答
  •  执笔经年
    2020-11-22 02:12

    Just a remark about your saying

    Hi, I tried searching a way to insert information in multiple tables in the same query

    Do you eat all your lunch dishes mixed with drinks in the same bowl?
    I suppose - no.

    Same here.
    There are things we do separately.
    2 insert queries are 2 insert queries. It's all right. Nothing wrong with it. No need to mash it in one.
    Same for select. Query must be sensible and do it's job. That's the only reasons. Number of queries is not.

    As for the transactions - you may use them, but it's not THAT big deal for the average web-site. If it happened once a year (if ever) that one user registration being broken you'll be able to fix, no doubt.
    there are hundreds of thousands sites running mysql with no transaction support driver. Have you heard of terrible disasters breaking these sites apart? Me neither.

    And mysql_insert_id() has noting to do with transactions. you may include in into transaction all right. it's just different matters. Someone raised this question out of nowhere.

提交回复
热议问题