多个表如何在单个查询中获取数据

时间:2019-03-19 09:52:50

标签: java

SELECT
     tbl_category.`cat_name` AS tbl_category_cat_name,
     registration.`firm_name` AS registration_firm_name,
     tbl_prod.`prod_name` AS tbl_prod_prod_name,
     tbl_prod.`prod_desc` AS tbl_prod_prod_desc,
     tbl_prod.`prod_size` AS tbl_prod_prod_size,
     tbl_prod.`prod_prate` AS tbl_prod_prod_prate,
     tbl_prod.`prod_mrp` AS tbl_prod_prod_mrp,
     tbl_prod.`prod_srate` AS tbl_prod_prod_srate,
     tbl_unit.`unit` AS tbl_unit_unit,
     tbl_brand.`bnd_name` AS tbl_brand_bnd_name
FROM
     `tbl_category` tbl_category,
     `registration` registration,
     `tbl_prod` tbl_prod,
     `tbl_unit` tbl_unit,
     `tbl_brand` tbl_brand

1 个答案:

答案 0 :(得分:0)

您可以使用Sql Join。请检查以下链接:https://www.geeksforgeeks.org/joining-three-tables-sql/

例如:

SELECT e.employeename
, e.employeeid
, e.employeedesc
, a.address
FROM employees e
INNER JOIN native nt
on e.employeeid = nt.studentid
INNER JOIN address a
  on nt.addressid = a.addressid