create database addressbook; OR CREATE DATABASE addressbook;
Note: SQL statements are case-insensitive, though table names and database names might be sensitive to case depending on the platform.
DESCRIBE employee_data;
INSERT INTO employee_data
(f_name, l_name, title, age, yos, salary, perks, email)
values
("Rudolf", "Reindeer", "Business Analyst", 34, 2, 95000, 17000, "rudolf@bignet.com");
Note: The text strings are enclosed in quotes.
SELECT emp_id, f_name, l_name, title, age, yos, salary, perks, email from employee_data; OR SELECT * from employee_data;
The second form is better and easier to type.
mysql> select f_name, email from employee_data; +---------+-----------------------+ | f_name | email | +---------+-----------------------+ | Manish | manish@bignet.com | | John | john_hagan@bignet.com | | Ganesh | g_pillai@bignet.com | | Anamika | ana@bignet.com | | Mary | mary@bignet.com | | Fred | fk@bignet.com | | John | john@bignet.com | | Edward | eddie@bignet.com | | Alok | alok@bignet.com | | Hassan | hasan@bignet.com | | Paul | ps@bignet.com | | Arthur | arthur@bignet.com | | Kim | kim@bignet.com | | Roger | roger@bignet.com | | Danny | danny@bignet.com | | Mike | mike@bignet.com | | Monica | monica@bignet.com | | Hal | hal@bignet.com | | Joseph | joseph@bignet.com | | Shahida | shahida@bignet.com | | Peter | peter@bignet.com | +---------+-----------------------+ 21 rows in set (0.00 sec)
SELECT salary, perks, yos from employee_data; mysql> SELECT salary, perks, yos from employee_data; +--------+-------+------+ | salary | perks | yos | +--------+-------+------+ | 200000 | 50000 | 4 | | 120000 | 25000 | 4 | | 110000 | 20000 | 4 | | 90000 | 15000 | 3 | | 85000 | 15000 | 2 | | 75000 | 15000 | 3 | | 80000 | 16000 | 4 | | 75000 | 14000 | 2 | | 70000 | 10000 | 3 | | 90000 | 15000 | 3 | | 85000 | 12000 | 2 | | 75000 | 15000 | 1 | | 110000 | 20000 | 2 | | 100000 | 13000 | 2 | | 90000 | 12000 | 1 | | 120000 | 28000 | 2 | | 90000 | 25000 | 3 | | 70000 | 18000 | 2 | | 72000 | 18000 | 2 | | 70000 | 9000 | 3 | | 120000 | 25000 | 4 | +--------+-------+------+ 21 rows in set (0.00 sec)
mysql> select salary, l_name from employee_data; +--------+------------+ | salary | l_name | +--------+------------+ | 200000 | Sharma | | 120000 | Hagan | | 110000 | Pillai | | 90000 | Pandit | | 85000 | Anchor | | 75000 | Kruger | | 80000 | MacFarland | | 75000 | Sakamuro | | 70000 | Nanda | | 90000 | Rajabi | | 85000 | Simon | | 75000 | Hoopla | | 110000 | Hunter | | 100000 | Lewis | | 90000 | Gibson | | 120000 | Harper | | 90000 | Sehgal | | 70000 | Simlai | | 72000 | Irvine | | 70000 | Ali | | 120000 | Champion | +--------+------------+ 21 rows in set (0.00 sec)
|
« Previous
|
Next »
|
Querying MySQL tables Our employee_data table now contains enough data for us to work with. Let us see how we can extract (query) it. Querying ...
Ordering data This section of the online MySQL tutorial looks at how we can change the display order of the data extracted from MySQL tables ...
selecting data using conditions In this section of the MySQL tutorial we'll look at the format of a SELECT statement we met in the last ...
IN and BETWEEN This section of the tutorial MySQL looks at the In and BETWEEN operators. To list employees who are Web Designers and System ...
Creating tables In this section of the mysql training course we will explore the MySQL commands to create database tables and selecting the database. Databases ...