HTML and CSS Reference
In-Depth Information
With a table ready, we can insert a few rows; each row has the name of a thing and a percentage that indicates
how awesome it is. remember that this is just for fun and to demonstrate MysQl is working:
INSERT INTO awesome_things (name, percent)
VALUES
('Wooden sunglasses', 72),
('Pabst Blue Ribbon', 85),
('Bands no one has heard of', 100),
('Vintage clothing', 67);
this should give you the following output:
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
Now that we know what's awesome, let's make sure we know all of the things that are more than 75 percent
awesome:
SELECT CONCAT(name, ': ', percent, '% awesome, which means I'm onboard.')
FROM awesome_things
WHERE percent>75
ORDER BY percent DESC;
Using CONCAT() allows us to combine the output into a sentence rather than just looking at raw data. Using
the WHERE clause, we can filter results so that we only see rows that are more than 75 percent awesome, and
because we want to see the most awesome things first, we order by the percent in descending order , or
high-to-low. When executed, you will see the following:
+----------------------------------------------------------------------+
| CONCAT(name, ': ', percent, '% awesome, which means I'm onboard.') |
+----------------------------------------------------------------------+
| Bands no one has heard of: 100% awesome, which means I'm onboard. |
| Pabst Blue Ribbon: 85% awesome, which means I'm onboard. |
+----------------------------------------------------------------------+
2 rows in set (0.00 sec)
Now that you know what's awesome, you may want to destroy the evidence by dropping the database altogether:
DROP DATABASE awesome_test_db;
this removes the database altogether so that your MysQl server isn't cluttered with test data.
 
Search WWH ::




Custom Search