Wednesday, 13 December 2017

Learn Sql server in hindi/urdu part-25 (many to many relationship)







create table tblstudent

(

st_id int primary key identity,

st_name nvarchar(20) not null

)

insert into tblstudent

values('Ali')

insert into tblstudent

values('Bilal')

insert into tblstudent

values('Zahid')

insert into tblstudent

values('Fahad')

insert into tblstudent

values('saleem')

insert into tblstudent

values('kamran')

select * from tblstudent



create table tblcourses

(

c_id int primary key identity,

c_title nvarchar(20) not null



)



insert into tblcourses

values('data structure')

insert into tblcourses

values('database&management')

insert into tblcourses

values('Data Audit')

insert into tblcourses

values('data warehosuing')

insert into tblcourses

values('data mining')

insert into tblcourses

values('data Analytics')



select* from tblcourses

select * from tblstudent







create table course_student

(

cs_id int primary key identity,

cs_fk_st int foreign key references tblstudent(st_id),

cs_fk_cu int foreign key references tblcourses(c_id),



)



insert into course_student

values(1,3)

insert into course_student

values(1,5)

insert into course_student

values(1,6)





insert into course_student

values(2,2)

insert into course_student

values(2,3)

insert into course_student

values(2,6)







insert into course_student

values(3,1)

insert into course_student

values(3,2)

insert into course_student

values(3,3)







select s.st_id,c.c_id,s.st_name,c.c_title from course_student cs inner join tblstudent s on s.st_id=cs.cs_fk_st inner join tblcourses c on c.c_id=cs.cs_fk_cu


No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...