Geeks Talk

Prepare for your Next Interview




interview question

This is a discussion on interview question within the SQL Server forums, part of the Databases category; Hello, It is Interview Quetion,I am joing 5 tables,if query is too long,what i have to do,what are the other option?...


Go Back   Geeks Talk > Databases > SQL Server

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-23-2008
Junior Member
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 9 Times in 2 Posts
nithya R is on a distinguished road
interview question

Hello,

It is Interview Quetion,I am joing 5 tables,if query is too long,what i have to do,what are the other option?
Reply With Quote
The Following 5 Users Say Thank You to nithya R For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 01-23-2008
Contributing Member
 
Join Date: Jun 2007
Location: Delhi, India
Posts: 50
Thanks: 0
Thanked 22 Times in 18 Posts
vikasvaidya is on a distinguished road
Re: interview question

other option is to use subquery for example

select * from table1 where col1 in (select col1 from table2 where col2 in (.................))))


----V V----
Vikas Vaidya
(Please mark the quote as thanks if u found the answer useful)
Reply With Quote
  #3 (permalink)  
Old 02-12-2008
Junior Member
 
Join Date: Feb 2008
Location: bangalore
Posts: 18
Thanks: 0
Thanked 2 Times in 1 Post
venkat.rbs is on a distinguished road
Re: interview question

Then go for coralated sub query...its give better performance also....
Reply With Quote
  #4 (permalink)  
Old 03-20-2008
Junior Member
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
luckyguy is on a distinguished road
Re: interview question

Hello,

Your question is not clear. From what I understood and will do

1. First check how many rows are there in the individual tables that need to be joined.
2. Then note down the foreign key columns.
3. Get the data in to temporary table(s) by joining 2 tables at a time which will be easy when writing the final query to output the result set.

Hope this helps.

Thanks
Reply With Quote
  #5 (permalink)  
Old 03-25-2008
Junior Member
 
Join Date: Mar 2008
Location: Chennai
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Jameelahmed_l is on a distinguished road
Cool Re: interview question

Hi Nithya !! Jameel here,
You can go for views as views are compiled select statements and can span across multiple tables
Reply With Quote
  #6 (permalink)  
Old 04-23-2008
Junior Member
 
Join Date: Apr 2008
Location: Hyderabad
Posts: 28
Thanks: 1
Thanked 4 Times in 2 Posts
nageshkota is on a distinguished road
Smile Re: interview question

Hai,

It is very much better to use the sub queries.
If we use the views it is nested upto 32 levels only..
If it crossed you may get errors.
Reply With Quote
  #7 (permalink)  
Old 04-28-2008
Junior Member
 
Join Date: Apr 2008
Location: Darbhanga
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vnsh4u is on a distinguished road
Re: interview question

use the views to simplify tasks
Reply With Quote
  #8 (permalink)  
Old 09-02-2008
Junior Member
 
Join Date: Feb 2008
Location: chennai
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
ckarthick is on a distinguished road
Re: interview question

views is the best solution for this.....
Reply With Quote
Reply

  Geeks Talk > Databases > SQL Server


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
interview on Informatica with Wipro...interview questions please chakri_kc Data Warehousing 2 03-05-2008 02:55 PM
Interview Related Question jnyanesh Interviews 3 02-12-2008 08:11 AM
Networking Interview question nikhil_rattan Interviews 0 01-18-2007 03:06 PM
Sybase Interview question & Answer lalushrivastava Database General 1 01-12-2007 04:35 AM
Idea to answer an interview question scott Interviews 1 07-29-2006 04:16 PM


All times are GMT -4. The time now is 01:04 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved