2011-03-31 63 views
0
**CategoryMaster** 

CategoryId Category Name 

1 ABC 

2 Xyz 

3 PQR 

**Product master** 

ProductId Name  

1  ABCD  

2  WXYZ  

3  UVWX  


**ProductCategory** 

ProCatID ProductId    CategoryId 

1  1  1 

2  1  2 

3  2  3 

4  3  2 

5  3  3 



**ProductDetail** 

ProductDetailId Price Qty  Date  ProductId 

1  250 8 2-11-2011 1 

2  200 10 2-12-2011 2 

我想featch從產品主表中的所有產品細節,其類別我的表結構同上如何寫這個

+0

@ user350140,你應該爲自己做一個忙,並標準化Product master表。將外鍵連接成一列是(幾乎)不是一個好主意。 – 2011-03-31 06:08:25

回答

0

你ProductMaster表SQL查詢不歸。這是不好的:你應該這樣建模:

Productmaster 
- productid 
- name 

ProductCategories: 
- productid 
- categoryID