In SQL Scripting, it is often required to reuse the queried values, while executing queries in sequence.
User defined variables are a good methodology to deal with above situation.
SELECT @publisher_id := @id from publisher where publisher_name = 'O'Reilly Media, Inc.' ;
INSERT IGNORE INTO
book (isbn, author, name, category, year, publisher_id)
VALUES
(9780596009205, 'Kathy Sierra, Bert Bates', 'Head First Java', 'Technology', 2013, @publisher_id );
https://www.devdummy.com/2018/06/mysql-execute-queries-with-variables.html
nice one and good one please visit my website https://technologyvanus.blogspot.com
ReplyDelete