SQL   « mysql - backup | HOME | mysql - database & table »

 ■ mysql - data input

Data input

Insert data on table
> insert into table1 values(data1, data2, data3, ....);
You need to quote a data by " or ' except digit. If you want to use " or ' in the data, input like \" or \'. (if you wanna use \ in the data then input like \\.)

You can indiate a field to input data like below.
> insert into table1 (column1, column2) values (data1, data2);

Multiple data can be input at the same time.
> insert into table1 (column1, column2, column3) values (data1, data2, data3), (data4, data5, data6)....;


Show data only for the particular columns in the table
> select column1, column2 from table1;

Show all data in the table
> select * from table1;


Create table with data

Create table with the column and data from other table
> create table table_name select * from existing_table;
After copied the column and data, you should check whether options are properly copied too with command 'desc' as sometimes it is not copied.


Insert all existing data into new table from the other table (the number of column and type in both table need to be matched.)
> insert into new_table select * from existing_table

Insert existing data from the particular column of the other table into the column of new table
> insert into new_table (new_column) select existing_column from existing_table;


投稿者 tomopugh : 2008年12月04日 16:01

Comment

I'm almost dying cos of the sql.
will get the inner join & sub query ! !

投稿者 sua : 2008年12月12日 23:43

Please comment !




Save the info?


  (Please don't click on "post" twice. It takes time a bit to change to the next screen!!)