insert-query

Inserting a time into mysql database in java

空扰寡人 提交于 2019-12-13 19:30:24
问题 I want to insert a time which is taken from a textbox to the mysql database TIME column. I suppose I need to convert String to TIME like converting String to Date in mysql using "STR_TO_DATE" in the query. I looked for answers but I didn't get the answer I required. Edit: SQL from comments: "insert into schedules ( courseid, batch, subjectid, teacherid, stime, etime, date, location, building, department, hall, status ) values ('" + getCourse() + "','" + getBatch() + "', '" + getSubject() + "'

Define Changeset for insert query in liquibase

穿精又带淫゛_ 提交于 2019-12-07 12:37:32
问题 I have two table as following : CREATE TABLE StudentMaster ( sId SERIAL, StudentName VARCHAR(50) ); CREATE TABLE StudentClassMap ( studnetId BIGINT UNSIGNED NOT NULL, studentClass VARCHAR(10), FOREIGN KEY (studnetId) REFERENCES StudentMaster (sId) ); This is my insert query. INSERT INTO StudentMaster (studentName) values ('Jay Parikh'); INSERT INTO StudentClassMap (studnetId, studentClass) values ((SELECT sId from StudentMaster where studentName='Jay Parikh'), 'M.Sc. 1st Year'); I want to

Define Changeset for insert query in liquibase

家住魔仙堡 提交于 2019-12-05 19:44:16
I have two table as following : CREATE TABLE StudentMaster ( sId SERIAL, StudentName VARCHAR(50) ); CREATE TABLE StudentClassMap ( studnetId BIGINT UNSIGNED NOT NULL, studentClass VARCHAR(10), FOREIGN KEY (studnetId) REFERENCES StudentMaster (sId) ); This is my insert query. INSERT INTO StudentMaster (studentName) values ('Jay Parikh'); INSERT INTO StudentClassMap (studnetId, studentClass) values ((SELECT sId from StudentMaster where studentName='Jay Parikh'), 'M.Sc. 1st Year'); I want to define ChangeSet for thes queries in liquibase . For First query ChangeSet will be : <changeSet author=

Insert new row with data computed from other rows

放肆的年华 提交于 2019-12-01 19:53:15
问题 Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ | Id | Type | Value | +----+------+-------+ | 0 | A | 1 | | 0 | B | 1 | | 1 | A | 2 | | 1 | B | 3 | | 2 | A | 5 | | 2 | B | 8 | +----+------+-------+ And, for each Id , I want to insert a new row with type C whose Value is the sum of the type A and B values for the rows of the same Id . The primary key on this table is (Id, Type) , so there's no question of duplication of Id,Type pairs. I can create the