如何从第一个表中选择*,只从连接表中选择x列?
SELECT *(TABLE1), TABLE2.id, TABLE2.name
FROM TABLE1
JOIN TABLE2
ON TABLE1.id_test = TABLE2.id
答案 0 :(得分:1)
尚未对其进行测试,但它应如下所示:
SELECT t1.*, t2.id, t2.name
FROM TABLE1 t1
JOIN TABLE2 t2
ON t1.id_test = t2.id
答案 1 :(得分:1)
SELECT table1.*, table2.id, table2.name
FROM table1
JOIN table2
ON table1.id_test = table2.id
答案 2 :(得分:0)
SELECT TABLE1.*, TABLE2.id, TABLE2.name
FROM TABLE1
JOIN TABLE2
ON TABLE1.id_test = TABLE2.id
虽然确实你确实想要那个*,因为如果你不想要所有列都是内存浪费。