SQL Query Basics

SQL Query Basics

Below is an example of a very basic SQL query:

SELECT

u.id AS 'id',  
u.username AS 'username',
u.firstname AS 'first name',
u.lastname AS 'last name',
u.email AS 'email'

FROM prefix_user AS u 

WHERE u.id > 2


The SELECT statement is used to select data FROM a database table. We can assign an alias to the database table using the AS statement as shown above. This is useful as it prevents you having to rewrite the database table over and over again when creating columns using the SELECT syntax.

id, username, firstname, lastname and email are all columns from the database table with the associated column heading you give them.

For more information on the Pluto LMS database tables, click here.


The WHERE clause is used to filter your records that fulfil a specified condition.

The above query will produce the following sample table:


id
username
first name 
last name
email
3
joesoap
Joe
Soap
js@e.com
4
salwhite
Sal
White
sw@e.com
5
themb
Them
B
tb@e.com
6
jess
Jess
Sky
js@e.com



For more help on SQL syntax, please visit https://www.w3schools.com/sql/




    • Related Articles

    • SQL Templates

      Note that assistance with writing SQL queries is not within Pluto LMS support scope. Please contact a developer for assistance. That being said, you can use the templates provided below to help you get started. Please review our other guides for more ...
    • Adding Filters

      OVERVIEW When creating a custom report, you can add filters that function as a control which produces a subset of data. ADDING A FILTER In the relevant custom report, in the "Filters" tab, select the filter that you require from the "Add" drop-down ...
    • Creating a Custom Report

      OVERVIEW The Custom Reports module allows you to create custom reports to supplement the native Pluto LMS reports. Note: This may require the assistance of a developer. USE CASE EXAMPLE: Improving Onboarding Training Company: XYZ Corporation ...
    • Using Tags for Reporting

      Overview Below is a list of explanations on how tags would be used in custom reports on Pluto LMS and how it is setup. A tag can be created and the name of that tag can be defined by the Client A tag will be assigned to an activity within a Pluto LMS ...
    • IP Blocker

      OVERVIEW Users with the "Site admin" role can set a list of allowed and/or blocker IP addresses in Site admin. Use Case Example: As a training manager, one of the challenges you may face is ensuring secure access to the LMS platform and protecting ...