通过两个表的列之间的外部映射连接mysql中的两个表
我想连接数据库中的两个表。我的第一张桌子看起来像通过两个表的列之间的外部映射连接mysql中的两个表,mysql,sql,join,inner-join,Mysql,Sql,Join,Inner Join,我想连接数据库中的两个表。我的第一张桌子看起来像 deviceId rssi date timestamp f po pps counter b Id f fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:08 0 100 26.36000061 3348 B2W 39 L1 fd00::212:4b00:1957:ce2f 60 10-1
deviceId rssi date timestamp f po pps counter b Id f
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:08 0 100 26.36000061 3348 B2W 39 L1
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:18 0 100 25.62000084 3349 B2W 41 L1
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:28 0 0 24.29999924 3350 B2W 46 L1
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:38 0 100 24.48999977 3351 B2W 48 L1
id date timestamp T hum temperature co r b block f location
fd00::212:4b00:1957:d625 10-12-2019 08:24.6 0 6618 2648 1454 99 null B2E L1 11
fd00::212:4b00:1957:d626 10-12-2019 13:23.2 0 6671 2630 1455 73 null B2E L1 12
fd00::212:4b00:1957:d627 10-12-2019 18:25.5 0 6681 2627 1456 73 null B2E L1 13
fd00::212:4b00:1957:d628 10-12-2019 23:23.3 0 6691 2626 1457 73 null B2E L1 14
fd00::212:4b00:1957:d625 10-12-2019 28:24.1 0 6701 2626 1458 73 null B2E L1 11
fd00::212:4b00:1957:d626 10-12-2019 33:24.1 0 6701 2626 1459 73 null B2E L1 12
我的第二张桌子看起来像
deviceId rssi date timestamp f po pps counter b Id f
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:08 0 100 26.36000061 3348 B2W 39 L1
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:18 0 100 25.62000084 3349 B2W 41 L1
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:28 0 0 24.29999924 3350 B2W 46 L1
fd00::212:4b00:1957:ce2f 60 10-12-2019 00:00:38 0 100 24.48999977 3351 B2W 48 L1
id date timestamp T hum temperature co r b block f location
fd00::212:4b00:1957:d625 10-12-2019 08:24.6 0 6618 2648 1454 99 null B2E L1 11
fd00::212:4b00:1957:d626 10-12-2019 13:23.2 0 6671 2630 1455 73 null B2E L1 12
fd00::212:4b00:1957:d627 10-12-2019 18:25.5 0 6681 2627 1456 73 null B2E L1 13
fd00::212:4b00:1957:d628 10-12-2019 23:23.3 0 6691 2626 1457 73 null B2E L1 14
fd00::212:4b00:1957:d625 10-12-2019 28:24.1 0 6701 2626 1458 73 null B2E L1 11
fd00::212:4b00:1957:d626 10-12-2019 33:24.1 0 6701 2626 1459 73 null B2E L1 12
有两个表,我想在第一个表的Id和第二个表的位置上连接它们。Id和位置之间有单独的映射。像
Id location
39 11
41 12
46 13
48 14
我将此映射单独保存在excel文件中。如果两个表中的列相同,我可以使用内部联接。当要联接的列之间存在外部映射时,我应该如何联接这些表。谁能帮我一下吗
谢谢将Excel数据加载到数据库中的表中。我怀疑MySQL能否“查看”Excel表。正如Gordon所说,将第三张(Excel表)上传到MySQL中。一旦你这样做了,查询就只是一个简单的连接了。但是我发现从Excel导出一个CSV文件,然后使用LOAD DATA LOCAL Infle将CSV文件导入MySQL更容易。如果您有权访问MySQL datadir,还可以使用CSV存储引擎定义表,只需将CSV文件放到datadir中的正确位置,即可将其作为表读取。但无论如何,我同意其他评论。您无法从MySQL查询Excel数据。必须以某种方式将映射数据加载到MySQL中,才能解决此问题。