Misc MySQL SELECT Examples

SELECT - All columns

Return all columns.

SELECT 
   *  
FROM Courses

SELECT - Return first 10 rows

Run a SQL Select statement and limit the number of rows returned. Useful when you are not sure of how to limit the recordset to be returned and you only want to return a few rows to do some initial analysis.

SELECT 
  course_designater , 
  course_name       , 
  employee_inactivating 
FROM Courses
LIMIT 10

SELECT - Count rows in table

Returns a count of the total number of rows in a table.

SELECT COUNT(*) from Courses

SELECT - Joining tables

Join two MySQL tables together.

SELECT 
       a.course_name                     , 
       b.class_start_date                , 
       b.class_end_date                          
 
FROM         courses a 
        JOIN classes b 
             ON  a.course_designater = b.course_designater_fk

WHERE a.course_name LIKE '%Perl%'
GO

 Collapse All    Expand All
Custom Search

MySQL Information and Resources