Exporting / Importing data in MySql

Importing data

mysql -h[host] -u[user] -p database < file.sql

Exporting data

mysqldump -h[host] -u[user] -p database > database.sql
mysqldump -h[host] -u[user] -p database table1 table2 > database_tables.sql

mysqldump –no-create-info -h[host] -u[user] -p database table1 table2 > database_tables.sql
mysqldump –no-data -h[host] -u[user] -p database table1 table2 > database_tables.sql

Advertisements

How to update a field with some value of that record

If you want to update a field with some value of that record with sql query.

update test u
inner join test temp on
    u.id = temp.id
set u.second_name = temp.first_name

Before updating the data
tb_b

After updating the data
tb_a