Friday, 22 April 2016

How to use variables in the MySQL query statements ?


Use @ symbol to denote the variables.
CONCAT function can be used to concatenate variables with strings.

Example
SET @district = 'DELHI';
SET @query_condition = CONCAT(' WHERE district=', @district);

SELECT id FROM user @query_condition;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.