This script gets all users from localhost in mysql.user table by using dynamic query.
SET @table = 'mysql.user';
SET @host = '''%localhost%''';
SET @s = CONCAT('SELECT * FROM ', @table, ' WHERE host LIKE ', @host);
PREPARE stmt3 FROM @s;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
Monday, January 4, 2010
Dynamic query in MySQL
at 6:04 PM
Labels: MySQL, MySQL Query
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment