加入两个没有关系的 SQL 表? [英] Joining two SQL Tables with no relationship?

查看:21
本文介绍了加入两个没有关系的 SQL 表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 MySQL 数据库中有 2 个表.一个是具有字段 ('landlord_id') 的旧表 (landlords).

I have 2 tables in a MySQL database. One is a legacy table (landlords) which has a field ('landlord_id').

另一个是 Joomla!1.7 名为 jos_users 的表,需要确保所有用户都是有效的 Joomla!用户和可以登录等.它有一个名为id"的字段.

The other is a Joomla! 1.7 table called jos_users which is needed to ensure all users are valid Joomla! users and can login, etc. It has a field called 'id'.

举个例子,我在 owner.landlord_id = 2 (John Smith) 中有一个现有的记录,但是没有相应的 jos_user.id 记录,因为在 jos_users 之前已经存在了 owners 表.

As an example I have an existing record in landlords.landlord_id = 2 (John Smith), however there is no corresponding jos_user.id record because the landlords table pre existed before the jos_users.

有没有办法使用 SQL 在两者之间建立/创建关系?

Is there a way to establish / create a relationship between the two using SQL?

我是否需要为房东创建 jos_user 记录(如果需要,如何创建?)?

Do I need to create jos_user records for the landlords (and if so how?)?

非常感谢任何建议或示例.

Any suggestions or examples are greatly appreciated.

推荐答案

您必须将数据从旧系统移植到新系统.我假设您使用的是 Joomla 的用户登录系统,对吗?在这种情况下,数据必须采用 joomla 正在查找的格式和位置,如果您理解的话.

You will have to port across the data from the old system to the new system. I assume that you're using Joomla's user login system right? In which case the data will have to be in the format and place joomla is looking for it in, if you understand.

如果不复制数据,您就无法真正创建链接".

You can't really create a "link" without replicating data.

我建议您可以做的是在房东的表中添加一个字段,即joomla_user_id.通过这种方式,您可以将 joomla 用户与旧系统中的房东记录相关联.这样您就不必手动移植任何内容,您可以构建应用程序以根据房东的 joomla 用户 ID 获取房东数据.

What you CAN do, which I suggest, is to add a field onto the landlord's table which is joomla_user_id. This way you can associate a joomla user with a landlord record from your old system. That way you don't have to manually port anything across, and you can build the app to get the landlord data based on their joomla user id.

这篇关于加入两个没有关系的 SQL 表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆