MySQL

Dynamic SQL , conditional where

SELECT first_name, last_name, subsidiary_id, employee_id
  FROM employees
 WHERE ( subsidiary_id    = :sub_id OR :sub_id IS NULL )
   AND ( employee_id      = :emp_id OR :emp_id IS NULL )
   AND ( UPPER(last_name) = :name   OR :name   IS NULL )


select * from mysql.user
where (user=NULL or NULL is null) 
and (host=NULL or NULL is null)

select * from mysql.user
where (user='root' or 'root' is null) 
and (host=NULL or NULL is null)

select * from mysql.user
where (user='root' or 'root' is null) 
and (host='127.0.0.1' or '127.0.0.1' is null)

MySql workbench Slackware64 14.1

mysqldump

Error MariaDB 5.5 mysqldump

Use /tmp/msd -h hostx -u userx -ppassx dbname > /tmp/dump.sql

Show users

   1 select host,user,password from mysql.user;

Create function

User creation and grants to select and execute function

   1 create user 'userx'@'%' identified by 'passwordx';
   2 grant select on dbx.tablex to 'userx'@'%';
   3 grant execute on function dbx.hello to 'userx'@'%';

MySQL (last edited 2014-10-22 21:11:33 by 73)