mysql - insert in database with column number -


i want insert in table using columns order not name

insert tablename(1,2,5) values('val1','val2','val3'); 

i dont want use

insert tablename values('val1','val2','val3'); 

because table not contain 3 columns

how can

because columns name encrypted can not rely on

insert  tablex("ccgsvkjvqxnt8a==","adoloqrpfg==","qsdcx112") values('val1','val2','val3'); 

is there idea how can deal

thank

you can't use ordinal number of column in insert statement. however, can accomplish you're trying (insert values specific columns in table) using column names instead.

presume table has 5 columns; i'm going call them "alpha", "bravo", "charlie", "delta", , "echo", since haven't given schema table, replace these names names of columns in table. i'm guessing third , fourth column (my "charlie" , "delta") nullable. can insert tuple/row in table other 3 columns filled using syntax this:

insert tablename(alpha, bravo, echo) values ("val1", "val2", "val3"); 

if, per comments above, column names unprintable characters (which terrible, terrible idea), can explicitly insert nulls missing columns:

insert tablename values ("val1", "val2", null, null, "val3"); 

but weakness here that, if additional columns subsequently added table's schema, insert statement start failing.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -