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
Define left outer join in sql server joins?
What is the difference between function and stored procedure in sql server?
Difference between uniqe index and uniqe constraint?
How global temporary tables are represented and its scope?
List types of tables in SQL Azure?
How to override dml statements with triggers?
Difference between primary key and clustered index?
What do you mean by subquery?
What is serializable?
1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?
Does partitioning help performance?
I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration
What is the difference between drop table and truncate table?
How do I partition a table in sql server?
What is a hint?