- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find out the records of students with more than a specific score in MySQL?
Set it with WHERE and get the records of students more than a specific score. Let us first create a table −
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentScore int -> ); Query OK, 0 rows affected (1.65 sec
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentName,StudentScore) values('John',43); Query OK, 1 row affected (0.81 sec) mysql> insert into DemoTable(StudentName,StudentScore) values('Sam',48); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(StudentName,StudentScore) values('Chris',33); Query OK, 1 row affected (1.50 sec) mysql> insert into DemoTable(StudentName,StudentScore) values('Robert',89); Query OK, 1 row affected (0.27 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+----+-------------+--------------+ | Id | StudentName | StudentScore | +----+-------------+--------------+ | 1 | John | 43 | | 2 | Sam | 48 | | 3 | Chris | 33 | | 4 | Robert | 89 | +----+-------------+--------------+ 4 rows in set (0.00 sec)
Following is the query to get the record of students with score more than 45 marks −
mysql> select StudentName from DemoTable where StudentScore > 45;
Output
This will produce the following output −
+-------------+ | StudentName | +-------------+ | Sam | | Robert | +-------------+ 2 rows in set (0.00 sec)
Advertisements