Computer Science, asked by IShipWolfstar74411, 10 months ago

Write a query to display the details of students like student id, student name, department name and phone number of students who are staying in hostel. Sort the records based on student id.

Answers

Answered by charlie1505
5

Answer

In Mysql query language

To display records in table

  • select stud_id, studname, dept, phone no from students;
  • Explanation- This query will fetch records from students table

To display sorted records.

  • SELECT * FROM `student` ORDER BY stud_id
  • This query will will sort all records in ascending order

Answered by StaceeLichtenstein
1

Select student _id, student _name

,department _name , phone_number

from students s and hostel h

on(s.hostel_id=h.hostel_id)

ORDER BY student_id ;

Explanation:

In this question, some information is missing and the column name is incorrect  

  • The column name student id ,student name ,department name and phone number never like that. There is never space between student id so we used underscore.
  • The second thing about this information is missing. There is also a hostel table That is holding hostel_id and another column.

       Description of query

  • Select query is used to fetching the record of the student.
  • In this query we created the two alias one for student i.e "s" and other for hostel i.e 'h".
  • We perform the equijoin for getting the result between the two tables.
  • Finally, Order by clause is used for sorting the record basis on the student_id

Learn More:

  • https://brainly.in/question/8493244
Similar questions