How to fetch records from a One to Many relationship table.
eg: wanna get details of all orders for a specific customer.
(do not want repeatation of master table records for child
table records)

Answers were Sorted based on User's Feedback



How to fetch records from a One to Many relationship table. eg: wanna get details of all orders fo..

Answer / syeda

Need to define a relationship to the table and common column
of tables

ex : there is a table called college which contains the
college records like studid, studentname, batch & course.
And other table called student_details which contains
studid, firstName, lastName, fathersName, mothersName, DOB,
ContactNo & address.

Here we are fetching studid, batch, course & studentname
from collete table and DOB, ContactNo & address from
students_details , of all the students whose birth month is
April 1988

Syntax : select
a.studid,a.batch,a.course,a.studentname,b.DOB,b.ContactNo,b.address
from college a, student_details b where a.studid=b.studid
and b.DOB like '%-Apr-1988'

Is This Answer Correct ?    4 Yes 0 No

How to fetch records from a One to Many relationship table. eg: wanna get details of all orders fo..

Answer / jagadeesh

SubQuery

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL Server Interview Questions

What are the advantages of stored procedure in sql server?

0 Answers  


Can group functions be used in the order by clause in ms sql server?

0 Answers  


What is BLOCK statements in SQL?

0 Answers   HCL,


What is the difference between clustered and non-clustered indexes in ms sql server?

0 Answers  


how many instance use in sql server 2005

4 Answers   EFI, HCL,






How to assign new column names in a view?

0 Answers  


Do you know exporting and importing utility?

0 Answers  


you want to be sure that queries in a database always execute at the maximum possible speed. To achieve this goal you have created various indexes on tables which other statement will keep the database in good condition? : Sql server administration

0 Answers  


Can you explain what is the use of custom fields in report?

0 Answers  


Explain the storage models of OLAP?

1 Answers  


What is the purpose of grouping data in a report?

0 Answers  


What do you mean by sql server agent?

0 Answers  


Categories