Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-04-2012, 06:16 AM   PM User | #1
kamal11
New to the CF scene

 
Join Date: Dec 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
kamal11 is an unknown quantity at this point
How to write Join Query for 3 tables

i have 3 tables:- sector, category, subategory

sector table
id->primary key
sector-name

category table
id->primary key
secid->Foreign key to sector table
category-name

subcategory
id->primary key
secid->Foreign key to sector table
catid->Foreign key to category table
subcat-name

now i want sector-name, category-name and subcat-name from 3 tables..how to join these 3 tables....
kamal11 is offline   Reply With Quote
Old 05-04-2012, 03:49 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,382
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
SELECT s.sector-name, c.category-name, sub.subcat-name
FROM `sector table` s, `category table` c, `subcategory` sub
WHERE s.id = c.secid
AND c.secid = sub.secid
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:36 PM.


Advertisement
Log in to turn off these ads.