Hello.
Please help with this question. There is a WORD table and a TRANSLATION table. Their fields are:
WORD(ID_WORD(primary),WORD) TRANSLATION(ID_TRANSLATION(primary),TRANSLATION,ID_WORD(foreign)) I want to first enter the word in WORD, and then copy it to the TRANSLATION table, but it does not work. Tell me what to do?
dbConnection = DbManager.getDBConnection(); statement = dbConnection.createStatement(); word = "INSERT INTO WORD (WORD) VALUES ('"+s[0]+"'); " +"SET @last_id_in_table1 = LAST_INSERT_ID(); " +"INSERT INTO TRANSLATION (ID_WORD,TRANSLATION) VALUES (LAST_INSERT_ID(),'"+s[1]+"');"; statement.execute(word); If anything, the error crashes like this: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ... If you specify the query in the mysql workbench, it works! But not from java (