SET @last_id_in_books = LAST_INSERT_ID(); INSERT INTO books_authors (bid, aid) values (@last_id_in_books, '$author'); INSERT INTO books_types (bid, tid) values (@last_id_in_books, '$type');