martes, 31 de agosto de 2021

subqueries

 SELECT (SELECT COUNT(*) FROM campaigns) as Campaigns, (SELECT COUNT(DISTINCT(list_name)) FROM lists where list_name!='TESTLOCAL' ) as list




You can do it by using subqueries, one subquery for each tableCount :

SELECT
  (SELECT COUNT(*) FROM table1 WHERE someCondition) as table1Count, 
  (SELECT COUNT(*) FROM table2 WHERE someCondition) as table2Count,
  (SELECT COUNT(*) FROM table3 WHERE someCondition) as table3Count

https://stackoverflow.com/questions/3761240/count-from-multiple-tables-in-mysql

jueves, 26 de agosto de 2021

create user and assign select permission to specific DB

 CREATE USER 'webdev'@'localhost' IDENTIFIED BY 'M1212';


GRANT SELECT ON dialer.* TO webdev@localhost IDENTIFIED BY 'M1212';


https://stackoverflow.com/questions/20036547/mysql-grant-read-only-options