MySQL. Add and modify table and data
In this lesson we’ll continue to learn MySQL – we will consider adding data with MySQL and modifying structure of table. In last lesson we created database and table in this database
First of all we will add two columns in our table. For this purpose MySQL has got alter table table_name add column_name operator. In fact this operator is universal for modification. Full syntax of this operator you can see on mysql site.
Data adding makes with INNER JOIN (see examples below).
It is important to notice about encoding. When you add data in Russian to table and then make selection, question marks can appear. This is because, table and database encoding didn’t set. You must rub this query ALTER TABLE table_name CONVERT TO CHARACTER SET utf8;
Data selection makes with SELECT (see examples below). You can add conditions to SELECT queries. To update data you must use UPDATE operator.
In the end we dropped our database with DROP DATABASE sport; query.