[英]Multiple MySQL Table Query
I could not find an answer by searching as I am not sure what exactly it would be called what I'm searching for. 我无法通过搜索找到答案,因为我不确定要搜索的内容到底是什么。
Anyways, I have multiple tables in MySQL and am trying to "fill in" some of the final product. 无论如何,我在MySQL中有多个表,并且正在尝试“填充”某些最终产品。
myTable
id assigned_to location
1 2 3
2 2 3
3 3 3
myUsers
id name
1 John
2 David
3 Sally
myLocation
id name
1 SAT
2 DEN
3 AUS
Basically the end product should pull the "myTable" data and fill into a table (which I already know how to do) the name and location of each row/column so that it states something alongm the lines of 基本上,最终产品应提取“ myTable”数据并将其填充到表(我已经知道该怎么做)中的每一行/列的名称和位置,以便在行的各行中声明某些内容。
ID Assigned To Location
1 David SAT
Instead of 代替
ID Assigned To Location
1 2 2
This should produce the expected result: 这应该产生预期的结果:
SELECT mt.id, mu.name, ml.name
FROM mytable mt JOINT myUsers mu ON mt.assigned_to = mu.id
JOIN myLocation ml ON mt.location = ml.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.