MySQL : Execute Queries with User Defined Variables - DevDummy

Latest

Guildes | Concepts | Techniques

Wednesday, June 20, 2018

MySQL : Execute Queries with User Defined Variables



Define the variable and set it in the server,


SET @country = 'Sri Lanka';
SET @section = 'Science Fiction';


Now you can write the query with placeholders,


SELECT book_name, isbn_number, author_id
FROM book_store 
WHERE published_in = @country 
AND category = @section;

...

No comments:

Post a Comment