The data table has been created. Assuming that we have inserted a lot of data, we can retrieve and display the information in the data table in the way we like. For example: we can put the entire data as follows The contents in the table are displayed
select * from president; The general form of the statement is as follows:
SELECT you want the information
from data table (one or more)
The conditions satisfied with
Select statement have several clauses, their various mixes can help Find the information you are most interested in. These clauses can be very simple or very complex. See how the author explains in detail
1. Use various operators to set search conditions
If you want to The select statement only retrieves records that meet specific conditions, so you must add a where clause to it to set the retrieval conditions for data rows. Only in this way can we selectively select those data rows whose data column values meet specific requirements. You can search for any type of value, for example, search for numerical values
select * from score where score>95; //Display all information with scores above 95 points
You can also search for string values
select last_name,first_name from president where last_name='Tom'; //Find all presidents with the last name tom
You can also perform a combined search on different types of values
select last_name,first_name,birth,state from president
where birth<'1950-1-1' and (state='VA' or state='BA');
//Find the president who was born in VA or BA before 1950
It can be seen that the arithmetic operators (+-*/%), comparison operators (<>=) and logical operators can be used in the where clause. We should be proficient in understanding the meaning of these operators (all simple)