sql - How to fetch data from tables where there is one to many relationship? -
i have created 3 tables product, brands , productbrands in ms sql server these tables contains info following
products (pid - pname)
1 - mobiles 2 - t.v 3 - a.cbrands (bid - bname)
1 - samsung 2 - sony 3 - l.gproductsbrands (pbid - pid - bid)
1 - 1 - 1 2 - 1 - 2 3 - 1 - 3 4 - 2 - 1 5 - 2 - 3...
...
now have fetch tables next feilds
product id pname bid bnamebasically have fetch brands assigned products
please help me!!! new this
select p.pid , p.pname, b.bid, b.bname products p bring together productsbrands pb on pb.pid = p.pid bring together brands b on b.bid = pb.bid
see, whether looking for.
sql sql-server sql-server-2008
No comments:
Post a Comment