2010年9月7日 星期二

use subquery to insert data

mysql>insert into persons values('tommy','lin','22','male');
insert one record to table persons

mysql>insert into customers(lastname,firstname) select lastname,firstname where age=22 and sex='male' from persons limit 1;

use subquery to get data that insert into another table customers

install mysql server on ubuntu

#apt-get update
#apt-get upgrade
update and upgrade the current os packages

#apt-get install mysql-server mysql-client
install mysql-server and client package

#mysql -u root -p
mysql>select version();

confirm the installion version of mysql

mysql>show databases;
show all databases you can access with your privileges;

mysql>use mysql;
use mysql database;

mysql>show tables;
show all tables with this database mysql