This is a table(called project) where I want to insert some data into it. enter image description here
And this is a table(called channel) where I am ready to find some data on it. enter image description here
Now I have a sequence like (name, maintainer, channelid, description,...) to insert, but I need channelname in channel table. That means, I must first look at channel table, and get data, finally insert into project it.
Can I use only mysql sentence to insert which means I only to need (name, maintainer, channelid, description,...) insert into project table, and makes mysql auto generate the column channelname?
And when I update channel table name column, can it be auto updated in project table.
I am using JDBC, it makes a little complex to insert it, like what I said
That means, I must first look at
channeltable, and get data, finally insert intoprojectit.
Also updating project when channel table changed is complex.So I am finding only use mysql method to make it.(Sadly,I can only use mysql by jdbc like jdbcTemplate.query("..."), so I hope the answer could be in this way)
)
CodePudding user response:
I thik it as it. UPDADTE project SET name =(SELECET name FROM channel WHERE channel.id = project.channelid) Where WHERE project.channelid = channel.id ;
