-> location_id INT(11) auto_increment Not NULL, -> location_name VARCHAR(30), -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 mysql> CREATE TABLE locations( -> location_id INT(11) auto_increment Not NULL, -> street_address VARCHAR(30), -> postal_code INT(11) auto_increment Not NULL, -> city VARCHAR(30), -> state_province VARCHAR(30), -> country_id INT(11), -> primary key(location_id), -> foreign key(country_id)REFERENCES countries(country_id) -> ); ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key mysql> CREATE TABLE locations( -> location_id INT(11) auto_increment Not NULL, -> location_name VARCHAR(30), -> country_id INT(11), -> primary key(location_id), -> foreign key(country_id)REFERENCES countries(country_id) -> ); Query OK, 0 rows affected (0.10 sec)
+-----------+-------------+ | region_id | region_name | +-----------+-------------+ | 1 | Europe | | 2 | America | | 3 | Asia | | 4 | Ethiopia | +-----------+-------------+ 4 rows in set (0.00 sec)
mysql> INSERT INTO countries
-> (country_id,region_id) -> values -> ('Argentina',2), -> ('Australia',3), -> ('Belgium',1), -> ('Brazil',2); ERROR 1366 (HY000): Incorrect integer value: 'Argentina' for column 'country_id' at row 1 mysql> mysql> INSERT INTO countries -> (country_name,region_id) -> ('Argentina',2), -> ('Australia',3), -> ('Belgium',1), -> ('Brazil',2); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Argentina',2), ('Australia',3), ('Belgium',1), ('Brazil',2)' at line 3 mysql> INSERT INTO countries -> (country_name,region_id) -> values -> ('Argentina',2), -> ('Australia',3), -> ('Belgium',1), -> ('Brazil',2); Query OK, 4 rows affected (0.05 sec) Records: 4 Duplicates: 0 Warnings: 0
mysql> SELECT*from countries;
+------------+--------------+-----------+ | country_id | country_name | region_id | +------------+--------------+-----------+ | 1 | Argentina | 2| | 2 | Australia | 3| | 3 | Belgium | 1| | 4 | Brazil | 2| +------------+--------------+-----------+ 4 rows in set (0.00 sec)
mysql> SELECT country_name from countries;
+--------------+ | country_name | +--------------+ | Argentina | | Australia | | Belgium | | Brazil | +--------------+ 4 rows in set (0.00 sec)
mysql> SELECT region_id from countries;
+-----------+ | region_id | +-----------+ | 1| | 2| | 2| | 3| +-----------+ 4 rows in set (0.01 sec)
mysql> SELECT DISTINCT region_id from countries;
+-----------+ | region_id | +-----------+ | 1| | 2| | 3| +-----------+ 3 rows in set (0.02 sec)