vadnica-logo
X

MySQL SELECT Statement

The SELECT statement is the fundamental SQL command for retrieving data from a database. It allows us to select exactly the data we need, filter it, and display it in the desired format. It is the most frequently used SQL command, as we need it every time we want to read data from a database.

SELECT column1, column2, ... // column names we want to display
FROM table_name// name of the table to retrieve data from    
EXAMPLE
RESULT
  1. Basic SELECT query that displays all data from the table "first_table". The asterisk (*) means all columns are selected.
    SELECT * FROM first_table;            
  2. Selecting only specific columns (first_name and last_name) from the "first_table". This is useful when we do not need all the data.
    SELECT first_name, last_name FROM first_table;            
  3. Using the WHERE condition for filtering - displays all records where the age is greater than 25.
    SELECT * FROM first_table WHERE age > 25;            
  4. Using the BETWEEN operator to select records within a certain range - displays all records with an age between 20 and 30.
    SELECT * FROM first_table WHERE age BETWEEN 20 AND 30;            
  5. Using BETWEEN with text values - displays all records where the name is alphabetically between "A" and "M".
    SELECT * FROM employees WHERE first_name BETWEEN "A" AND "M";            

Thank you for visiting! Adding privacy policy.

© 2024 All rights reserved.

Vam je koda pomagala? Če želite podpreti moj trud pri pripravi vodičev in vzdrževanju strani, mi lahko namenite donacijo za kavo.