MySQL - How to create a new table that is a join on primary key of two existing tables

前端 未结 4 1794
旧巷少年郎
旧巷少年郎 2021-02-05 17:39

I have two existing tables, with different fields, except for Primary ID (a varchar, not an int). I want to create a third table which is essentially a

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 18:20

    Why are you creating a new table? Why don't you just execute a query whenever you need the data? If you're just joining two tables on their primary key, then the majority of your data access time is going to be spent marshalling the data back to your application. You're not going to be saving much time pre-joining the tables, and you'll be eating a lot of space. Plus, you're taking aim at your big toe, just waiting for the first time you update your source tables and forget to run your update script to copy the changes to your joined table. Duplicate data is evil, but sometimes it's necessary. This doesn't sound like one of those times.

提交回复
热议问题