Look at the table “ Student” given below and solve the following:-
a) Write the code to create the table “student” above.
b) Write the code to Insert the value in a table all three rows
c) Write the sql query to display all the data from the table
d) Write the query to display the names of all the male students.
e) Display all the details of students who belong from jmt
f) Display the details of all the student whose address is not given.
g) Display unique address from student table
h) Display all the details of students arranged in descending order of their name.
i) Display admno and name of those students who belong from ’ 12a’ and ‘12b’
j) Display all the details whose class is 12a arranged in ascending order of their name.
Attachments:
Answers
Answered by
13
a) Write the cσde to create the table “Student".
- Creαte tαble Student(Admno int(3) Primαry Key, SName vαrchαr(20), Class vαrchαr(3), Address chαr(3), Gender vαrchar(6));
b) Write the cσde to insert the values in the table.
- Insert into Student values(123, 'Rahul', '12A', 'jmt', 'Male');
- Insert into Student values(124, 'Puja', '12A', 'dhn', 'Female');
- Insert into Student values(125, 'Sundar', '12B', Null, 'Male');
- Insert into Student values(126, 'Rajan', '12A', 'jmt', 'Male');
c) Write the command to display all the data from the table.
- Select * from Student;
d) Write the command to display the names of all the male students.
- Select SName from Student where Gender = 'Male';
e) Display all the details of students who belong from jmt.
- Select * from Student where Address = 'jmt';
f) Display the details of all the students whose address is not given.
- Select * from Student where Address is Null;
g) Display the unique addresses from the table.
- Select distinct Address from Student;
h) Display all the details of students arranged in descending order of their names.
- Select * from Students order by SName desc;
i) Display AdmNo and Names of those students who belong to ’12A’ and ‘12B’.
- Select Admno, SName from Student where Class = '12A' or Class = '12B';
j) Display all the details of those students whose class is 12A arranged in ascending order of their names.
- Select * from Student where Class = '12A' order by SName;
Anonymous:
Awesome as always
Similar questions