使用 MYSQL 而不是 MSSQL 进行跨表联接

发布于 2024-07-09 06:26:44 字数 321 浏览 4 评论 0原文

mysql 中是否可以跨不同表进行跨表连接? 在不同的数据库中。

这在MSSQL中似乎很容易实现,并且大大加快了数据传输速度?

mysql呢,需要使用强大的IDE来实现吗? 或者你必须编写一个程序来做这样的事情吗?

更新表用户 SET tblUser.ReceiveInfo=old_database.dbo.contact.third_party_info_yn FROM tblUser 内连接 old_database.dbo.contact ON old_database.dbo.contact.id=tblUser.oldid

Is it possible to do a cross table join in mysql spaning different tables? in different databases.

This seem to be easily possible in MSSQL, and greatly speeds up data transfer?

How about mysql, do you need to use a powerful IDE to achieve this? or do you have to write a program to do something like this?

UPDATE tblUser
SET tblUser.ReceiveInfo=old_database.dbo.contact.third_party_info_yn
FROM tblUser inner join old_database.dbo.contact
ON old_database.dbo.contact.id=tblUser.oldid

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

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

发布评论

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

评论(3

衣神在巴黎 2024-07-16 06:26:44

当然,非常容易。 在表名前面加上数据库名称前缀,如您所示。 我们定期进行跨数据库连接。 例如:

从 newusers1.users 中选择 COUNT(*)
加入newusers2.users

当然不会加快数据传输速度。

现在,如果您的表位于不同的数据库服务器上,那么答案是否定的。 一个例子是,如果您的数据库太大并且您需要对表进行分片。 事情变得有点混乱了。 但考虑到您似乎对 MS SQL 解决方案感到满意,这似乎并不适用于此。

Sure, very easy. Prefix the table name with the database name, like you show. We do cross-database joins on a regular basis. For example:

SELECT COUNT(*) FROM newusers1.users
JOIN newusers2.users

It certainly won't speed up data transfer compared to having both tables in the same database, though.

Now, if your tables are sitting on different database servers, the answer is no. An example of this is if your database is too big and you need to shard your tables. Things get more than a little messy. But given that you seem to be happy with the MS SQL solution, that does not seem to apply here.

安人多梦 2024-07-16 06:26:44

在 MySQL 中,您可以进行跨数据库联接,并且通过 FEDERATED 引擎,甚至可以进行跨服务器联接。

In MySQL you can do cross DB joins and, by way of the FEDERATED engine, even cross server joins.

岁月蹉跎了容颜 2024-07-16 06:26:44

MySQL实际上并不关心这些表是否在同一个“数据库”中,它只是表的逻辑集合,以便于管理、权限等。

因此,您可以在它们之间进行联接,就像它们在同一个“数据库”中一样容易(参见克里斯在埃德蒙顿的回答)

MySQL doesn't actually care if the tables are in the same "database", it's just a logical collection of tables for convenient administration, permissions etc.

So you can do a join between them just as easily as if they were in the same one (see ChrisInEdmonton's answer)

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