| Author: gopal.net 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi,
In both tables u need to put one common column. Bcoz to put relation but 2 tables.
then use inner join by taking alias name
gopal
|
| Author: Dni 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
The two tables doesnt have relation.how can i write the query?
|
| Author: gopal.net 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi,
U have to take common column other wise u can't.
this is sample query for u question.
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName
|
| Author: gopal.net 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi,
wht r two table names n columns in tht
|
| Author: Dni 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
table names are table1(name,phone,id),table2(mobile,address)
|
| Author: gopal.net 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi,
ok take id as common field in both tables.
then use
SELECT a.name, a.phone, b.mobile,b.address FROM table1 a INNER JOIN table2 b ON a.ID=b.ID
where a and b are alias names for 2 tables
|
| Author: gopal.net 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
hi,
is it helpful
gopal.net
|
| Author: Miss Meetu Choudhary 04 Jul 2009 | Member Level: Diamond | Rating:  Points: 2 |
Please Use proper title
Thanks and Regards Miss Meetu Choudhary (Site Coordinator) Go Green Save Green My Profile on Google
|
| Author: Devendra 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Dear,
You have to keep Primary and Foreign key Concept. If you have then you can use following query
Select table1.name,table1.phone,table2.mobile FROM table1, table2 Where table1.PrimaryColumnName = table2.ForeignColmunName
If You Don have Then You can use Inner Join but it will not give you proper result
Thanks dkmisra
|
| Author: pradeep 05 Jul 2009 | Member Level: Silver | Rating:  Points: 2 |
use inner join
|
| Author: Williams 05 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi
If u not have minimum one common field to both the tables, its impossible to join two tables.
|