在另一个表的帮助下连接两个表 - MySQL连接

时间:2016-04-08 15:01:47

标签: mysql join

我有三个表first secondf_s,它们将两个表连接在一起,如下所示

first_id │  first            second_id │ second         first_id │ second_id
   1       station               1       address            1       1 
   2       hospital              2        point             1       2 
   3       hotel                                            2       1
                                                            2       2
                                                            3       1

对于给定的second.second_id,我需要second.secondfirst.first。我该如何编写mySQL查询?

示例: station

first  │ second_id│  second
station      1       address
station      2       point

1 个答案:

答案 0 :(得分:0)

这将是三个表的简单连接。

var arr1 = ["a1", "a2", "a3", "a4", "a5"]
var arr2 = ["b1", "b2", "b3", "b4", "b5"]
newArr = []
t1 = t2 = temp = []

while(arr1.length) {
  t1 = arr1.splice(0,3)
  t2 = arr2.splice(0,3)
  temp = t1.concat(t2)
  newArr = newArr.concat(temp)
}
console.log(newArr)