I have a table with the following structure:
(table_name, column_name)
and for each row in this table, I need to query column_name in table_name and make COUNT(column_name) GROUP BY column_name values ββthere.
I'm currently doing
SELECT * FROM this table foreach row: do another query with: SELECT column_name, COUNT(column_name) GROUP BY column_name
Is there a way to do this in a single request? Sort of
SELECT column_name, COUNT(column_name) GROUP BY column_name FOREACH(SELECT table_name, column_name FROM my_initial_table)
I know that the last request is invalid, this is just an example of what I want to achieve, if possible.
LE:
The table that indicates where to look has 2 varchar columns
Example:
|++++++++++++++++++++++++++++++++ | table_name | column_name | |+++++++++++++++++++++++++++++++| | logsa | foo | |===============================| | logsa | bar | |===============================| | testx | baz | |===============================|
This tells me that now I also look in the foo and bar columns of the logsa table and the baz column of the testx table
Each column in each table has a VARCHAR as a data type, and I just need to count the same. so i did
SELECT column_name, COUNT(column_name) GROUP BY column_name
source share