Category: MariaDB Database

Added: 25th of September 2022

Updated On: 25th of September 2022

Viewed: 2,905 times

Related Tips & Tutorials

Install MariaDB database in Ubuntu based distributions 2022 (Part 1)

Create a new user using MariaDB database in the Linux Terminal (Part 2)

Create a new database, table and insert data, using MariaDB in the Linux Terminal (Part 3)


This article was updated and rechecked on 25th of September 2022

Perform basic SELECT queries in MariaDB using the Linux Terminal (Part 4)

In the last tutorial we created a new database in MariaDB, we also created a new table with some fields and inserted some data.
The data included information about English football teams, their nicknames, stadium_name and capacity.

In this tutorial we will use basic MySQL queries to output information from the database.

Display all records from the table. Display records by id number, in ascending order

SELECT * FROM teams ORDER BY id ASC;




Display all records from the table. Display records by id number, in descending order
SELECT * FROM teams ORDER BY id DESC;




Display all records from the table. Display records by name
SELECT * FROM teams ORDER BY team;




Display all records but only the team field. Display records by id number, in ascending order
SELECT team FROM teams ORDER BY id ASC;




Display all records but only the team and nickname fields. Display records by id number, in ascending order
SELECT team, nickname FROM teams ORDER BY id ASC ;




Count the total number of records in teams table
SELECT COUNT(id) FROM teams;




Display all records where the field capacity is more than 30000 but less than 35000
SELECT * FROM teams WHERE capacity > 30000 AND capacity < 35000;




Display records from the team field beginning with the letter b
SELECT * FROM teams WHERE teams LIKE 'b%';




Display records from the team field beginning with the b and a
SELECT * FROM teams WHERE team LIKE 'b%' OR team LIKE 'a%';