Write a query to display all student details whose sname starts with ‘s’(case sensitive) and is of length between 5 and 20 and squal as ‘undergraduate’(case sensitive). Display the records sorted in ascending order based on sid.
Question
Write a query to display all student details whose sname starts with ‘s’(case sensitive) and is of length between 5 and 20 and squal as ‘undergraduate’(case sensitive). Display the records sorted in ascending order based on sid.
Solution
Assuming you are using SQL, the query would look like this:
SELECT *
FROM Students
WHERE sname LIKE 's%'
AND LENGTH(sname) BETWEEN 5 AND 20
AND squal = 'undergraduate'
ORDER BY sid ASC;
Here's the step by step explanation:
-
SELECT * FROM Students: This part of the query selects all columns from the "Students" table. -
WHERE sname LIKE 's%': This condition filters the records and only selects the students whose names start with 's'. The '%' is a wildcard character that matches any sequence of characters. -
AND LENGTH(sname) BETWEEN 5 AND 20: This condition further filters the records and only selects the students whose names have a length between 5 and 20 characters. -
AND squal = 'undergraduate': This condition further filters the records and only selects the students who are undergraduates. -
ORDER BY sid ASC: This part of the query sorts the resulting records in ascending order based on the student ID (sid).
Similar Questions
Write a MySQL statement to sort the students in descending order of the last name
Write a query to display the student qualification(squal) and the total number of students based on their qualifications. Give an alias name as ‘totalStud’. Display only the squal having the totalStud count less than 8. Display the records sorted in ascending order based on squal.
Consider these following tables and only solve the query. Tables: 1) student: s_no (primary key), student_name, course_no (foreign key), age 2) courser-course-no (primary key), course-name. Query: Display all the student name, course name and also age of the students, whose age is between 23 to 27 and course having 'BCA'. Find out the students whose age is maximum.
ou have a database that tracks students in the students table by student_id. Students may get warnings for low grades or poor behavior. The warnings are tracked in the warnings table where the student is referred to by student_id.You need to create a query that finds the first and last name of the student who has the most records in the warnings table. You begin typing your query:What should you type in the blank space? (Please type your answer all in lower case. Example: select)
Write a query to display the subject_name and subject_code of the subjects handled by the staff named 'Lakshmi'. Display the records sorted in ascending order based on subject_name.Note:1. Display only the subject_name and subject_code of the subjects handled by the staff named 'Lakshmi'.2. Use Joins. Tables involved are subject and staff3. Order by is mandatory.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.