如何連接三個具有一個公共列(id)的mysql表,例如,從Table1中選擇a,b,從table2中選擇c,d,從table3中選擇e,f,其中id = X 感謝mysql join 3表
2
A
回答
2
SELECT `table1`.`a`,`table2`.`c` .....
FROM `table1` JOIN `table2` USING(`id`) JOIN `table3` USING(`id`)
WHERE `id` = x
2
SELECT t1.a, t1.b, t2.c, t2.d, t3.e, t3.f
FROM table1 t1, table2 t2, table3 t3
WHERE t1.id = t2.id
AND t2.id = t3.id
AND t3.id = x
3
SELECT t1.a, t1.b, t2.c, t2.d, t3.e, t3.f
FROM `table1` t1
JOIN `table2` t2 ON t1.id = t2.id
JOIN `table3` t3 ON t1.id = t3.id
WHERE t1.id = x
9
SELECT t1.a, t1.b, t2.c, t2.d, t3.e, t3.f
FROM table1 t1
JOIN table2 t2 ON (t1.id = t2.id)
JOIN table3 t3 ON (t1.id = t3.id)
ORDER BY t1.id;
0
SELECT col1,col2,col3 (select any col from any table)
FROM t1 INNER JOIN t2,t3
WHERE t1.id = t2.id
AND t1.id = t3.id;
0
請嘗試此查詢:
SELECT product_details.product_id, product_name.pro_name,categories.cat_name
FROM product_details
INNER JOIN product_name
ON product_details.product_id=product_name.id INNER JOIN categories ON product_details.categories_id=categories.id order by product_details.id;
相關問題
- 1. MySQL JOIN的3個表
- 2. MySQL的活動聯盟JOIN 3個表
- 3. MySQL INNER JOIN 3個表格,也使用INNER JOIN DELETE使用
- 4. JOIN MySQL表
- 5. JOIN 3個表查詢
- 6. mysql query join/inner join
- 7. 多個表Mysql JOIN
- 8. mysql count and join
- 9. MySQL JOIN ARRAY
- 10. MySQL的:INNER JOIN
- 11. INNER JOIN在MySQL
- 12. LEFT JOIN(mysql)
- 13. 我想在mysql的3個表中使用left和inner join?
- 14. 爲什麼我的3表JOIN MySQL查詢不起作用?
- 15. MySQL的JOIN 3代表在一個查詢
- 16. SQL JOIN表3所有查詢組合
- 17. MySQL Query LEFT JOIN 5表
- 18. JOIN 2個表MySQL查詢
- 19. MySQL Select JOIN多個表
- 20. MySql JOIN表作爲內容?
- 21. 通過JOIN導出MySQL表?
- 22. MySQL LEFT OUTER JOIN虛擬表
- 23. MySQL JOIN/GROUP_CONCAT第二個表?
- 24. MYSQL LEFT JOIN結果與表?
- 25. MYSQL LEFT JOIN其他表
- 26. MySQL JOIN表與WHERE子句
- 27. MySQL JOIN不規則表
- 28. Natural join mysql 5.6
- 29. 從3個MySQL表
- 30. MySQL Join Issue
請使用'{}'格式化代碼。 – codeforester 2017-02-03 05:37:36