Click here to Skip to main content
15,881,649 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to join two tables in sql server 2008?

can any one tell me step by step process!!
Posted
Comments
S.P.Tiwari 5-Dec-11 5:23am    
which type of join you want..?can you be more specific

UsersTable       UserRolesTable

PK user_id       PK user_role_id
FK user_role_id     role_description   
   username     
   password


SQL
SELECT A.username, B.role_description
FROM UsersTabel A
INNER JOIN UserRolesTable B
ON A.user_role_id = B.user_role_id


Thru that very simple example, hope you get it ;)

After that, move to the more advance one. See link below.
Visual Representation of SQL Joins[^]

Regards,
Eduard
 
Share this answer
 
same like
which join you want?
SQL
SELECT order_id, product_name, unit_price, supplier_name, total_units
FROM product, order_items
WHERE order_items.product_id = product.product_id;


or another Syntax
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
 
Share this answer
 
Comments
[no name] 5-Dec-11 5:50am    
Thanq, I want Inner join, can u explain one example for inner join....
Abhi KA 5-Dec-11 6:31am    
k
RatheeshS 30-Jan-13 7:29am    
i want one inner join example
 
Share this answer
 
Comments
[no name] 5-Dec-11 6:13am    
Thanq so much it is very useful to me!!
SQL
SELECT FLD1, FLD2 FROM TABLE1 INNER JOIN TABLE2 
ON TABLE1.PRIMARY_KEY=TABLE2.FOREIGN_KEY


OR

SQL
SELECT FLD1, FLD2 FROM TABLE1 , TABLE2 
WHERE TABLE1.PRIMARY_KEY=TABLE2.FOREIGN_KEY



Above we are matching the fields of both the tables and extract the record only when the record exists in both the tables.

In case of Inner join above both are same and you can use as you like.
 
Share this answer
 
SQL
SELECT productID,productName,categoryName
FROM products
INNER JOIN categories ON products.categoryID = categories.categoryID


here Product and categories are tables
go thru this
http://www.sqltutorial.org/sqljoin-innerjoin.aspx[^]
 
Share this answer
 
Comments
Abhi KA 5-Dec-11 6:40am    
is it usefull?
[no name] 5-Dec-11 6:44am    
he given some useful links... it is very clear!!
[no name] 5-Dec-11 6:48am    
u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900