By using SELECT
statement we can reterive data from database.
Here is some examples of fetching data with SELECT
.
-- select first_name, last_name and email columns from users table
SELECT first_name, last_name, email FROM users;
-- +-------------+-------------+---------------------------------------+
-- | first_name | last_name | email |
-- |-------------+-------------+---------------------------------------|
-- | Carmen | Malone | [email protected] |
-- | Stephanie | Wallace | [email protected] |
-- | Brandon | Jenkins | [email protected] |
-- ...
-- select all columns from users table
SELECT * FROM users;
-- +-----+---------------------+-------------+-------------+---------------------------------------+-------------------------+--------+
-- | id | datetime_joined | first_name | last_name | email | city | active |
-- |-----+---------------------+-------------+-------------+---------------------------------------+-------------------------+--------|
-- | 1 | 2023-08-18 21:44:13 | Carmen | Malone | [email protected] | East Jeanmouth | True |
-- | 2 | 2023-07-27 04:31:11 | Stephanie | Wallace | [email protected] | West Misty | True |
-- | 3 | 2023-01-30 08:00:52 | Brandon | Jenkins | [email protected] | Pinedamouth | True |
-- ...