使用另一个表中的值在 MYSQL / Navicat 列中创建表

发布于 2025-01-06 05:41:26 字数 542 浏览 3 评论 0原文

现在这可能是我想象的东西,或者是真实的东西,无论哪种方式,我都被谷歌困住了(其他搜索引擎可用......实际上没有)

我曾经在其他人设置的一些mysql表上工作,我正在使用 navicat,我将数据插入到该表中,并到达一个只能用另一个表中的值填充的字段,有一个下拉框和所有内容(尽管我知道这是 navicat 所做的),就像它有一些表之间的某种编码链接。这给我留下了深刻的印象,以至于我敬畏地张大了嘴。

我现在想知道我是如何做到这一点的,因为它似乎非常适合我的链接表,你知道 id_from_table_1 链接到 id_from_table_2 表。特别是在设置时提供的 navicat 下拉框,如果它可以像选择框一样工作,我可以在列表中看到项目的名称,但它会插入 id -> ,那就更好了。我知道我在这里的要求可能有点太多了,无论如何,我的第一个问题引起了我的兴趣。这是 mysql 中的某个编码链接还是 navicat 中编码的某个函数?不管怎样,我都非常想重新创造它,这样我就可以像一个巫师一样出现在我的大学里,甚至可能在那些看到我出色技能的人中获得“哈利·波特”的称号。

Now this may be something I imagined, or something real either way I am stuck on what to Google for (other search engines are available....no really there are)

I was once working on some mysql tables somebody else had set up, I was working with navicat and I went to insert data into this table and got to a field that could only be populated with values from another table, had a drop down box and everything (though I know that was navicats doing) like it had some sort of coded link between the tables. This impressed me, so much so that I opened my mouth wide in awe..

I am now wondering how I do this, as it seems perfect for my linking tables, you know the id_from_table_1 links to id_from_table_2 tables. Especially with the drop down box navicat offered when this was set up, better still if it could work like a select box where I see the name of the item in the list but it inserts the id -> I know I may be asking for a little too much here, either way the first of my queries intrigues me. Was this some coded link in mysql or some function coded into navicat? either way I would very much like to recreate it, so I to can appear like a wizard to my colleges perhaps even gaining the title "Harry Potter" amongst those that see my awesome skills.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁梦 2025-01-13 05:41:26

在 Navicat 中,转到工具 ->数据传输。选择源和目标,嘿,很快,您的传输就完成了。如果这不合适,那么您可能需要手动组合 UPDATE 查询,以根据另一个表中的字段手动更新一个表中的字段。

In Navicat, go to Tools -> Data Transfer. Select source and target, and hey presto that's your transfer done. If that isn't suitable then you may need to put together an UPDATE query manually to manually update fields in one table based on fields in another.

夏末 2025-01-13 05:41:26

我通过点击发现我正在谈论外键。一旦正确设置,Navicat 可以提供一个包含外部表详细信息的下拉框,使数据输入变得更容易,并且不太容易出现人为错误:)更不用说更快的表请求,这很好:)

设计表- >Options(tab)->Engine->InnoDB(对于两个表)
然后
设计表->外键(选项卡)->

现在填写各种详细信息,当通过 Navicat 在带有键的字段上将数据输入到表中时,它将显示一个下拉图标,单击该图标,然后点击设置并选择数据来自您要显示的外部表。

方便的关系表

现在

| client_id | product_id |
--------------------------
|     1     |     23     |
--------------------------
|     1     |     98     |

更容易使用,因为在 Navicat 中输入 Product_id 会向我显示产品表并让我选择一个,对于客户表也是如此。

纯粹的天才:)

I found out by clicking around that I was talking about foreign keys. Once set-up properly Navicat can provide a drop-down box with the foreign table details, making data entry that little bit easier and that little less prone to human error :) not to mention faster table requests which is nice :)

Design Table->Options(tab)->Engine->InnoDB (for both tables)
then
Design Table->Foreign Keys(tab)->Fill out various details

now when entering data into the table via Navicat on the field with the key it will show a drop-down icon, click that then hit settings and choose the data from the foreign table you want to display.

handy for relations table

now

| client_id | product_id |
--------------------------
|     1     |     23     |
--------------------------
|     1     |     98     |

is a lot easier to play with as entering a product_id in Navicat will show me the products table and let me select one, and same for the client table.

pure genius :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文