Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have two table names student and studentinfo.
in student table stuid(primary key) studentname.
in studentinfo stuid(foreign key) local address,permenant address etc..
now what i wanted to do is that when i going for using gridview i wanted to display
student name in student info table.. than how can do this??
pls reply.....
Posted

1 solution

You need to use a join. They work like this:

select studentname, [local address], <other fields="" as="" required=""> from student inner join studentinfo on student.stuid = studentinfo.stuid

Inner join gives you records where there is s match in both tables. If there's a chance of no match in both tables, use a left join instead.

Of course, if there is only ever a single studentname mapped to each studentinfo row, then the question needs to be asked why they are in separate tables at all!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900