I have to display ten columns values from diffrent ten
tables.
how many joins are require?
Answer Posted / b.kumar
--MS SQL SERVER
WE CAN DISPLAY RECORDS BY USING 9 JOINS
SELECT TBL1.COLUMN1,TBL2.COLUMN2,---------,TBL10.COLUMN10
FROM TBL1 INNER JOIN TBL2 ON TBL1.ID=TBL2.ID
INNER JOIN TBL3 ON TBL1.ID=TBL3.ID
----
----
----
INNER JOIN TBL10 ON TBL1.ID=TBL10.ID
----------------------------------------
--WE CAN ALSO DISPLAY THE RECORDS WITH OUT USE JOINS
SELECT TBL1.COLUMN1,TBL2.COLUMN2,---------,TBL10.COLUMN10
FROM TBL1,TBLE2,--------,TBL10
WHERE TBL1.ID=TBL2.ID OR TBL1.ID=TBL3.ID OR
----
----
----
TBL1.ID=TBL10.ID
--WE MUST USE WHERE CLAUSE OTHER WISE WE GET Cartesian product.
--------------------------------------------------
WE CAN'T JOIN DIFFERENT TABLES OF COLUMNS BY USING UNION
BECAUSE UNION COMBINES THE TWO OR MORE RESULT SETS
(IT MEANS ROWS)
DIFFERENCE BETWEEN JOIN & UNION
-- JOIN COMBINES TWO OR MORE THE COLUMNS
-- UNION COMBINES TWO OR MORE ROWS
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is application role in sql server database security? : sql server security
Can you roll back the ddl statement in a trigger?
What are the diifferences between the ms sql server vs mysql?
How you can move data or databases between servers and databases in sql server?
Can I work with several databases simultaneously? : sql server management studio
How to get the number of affected rows?
Explain differences between web edition and business edition?
What is the purpose of forms?
As a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this?
What are blobs, tables, and Queues? Is SQL is the standard way to query blobs, tables, and queues?
Tell me the use of keyword with encryption. Create a store procedure with encryption?
How to use clusters?
Explain what is the function of sql server agent windows service?
How do I run sql server 2014?
Mention the differences between having and where clause.