I have a lot of tables with the same _ips endings. Example:
first-domain.com_ips
secons-domain.com_ips
...
I'm trying to get UNION result table which will contains all rows from all _ips tables. For this I use:
SELECT id, expirationDate FROM `first-domain.com_ips` WHERE isBlocked = 1
UNION
SELECT id, expirationDate FROM `secons-domain.com_ips` WHERE isBlocked = 1
...;
I have an array which consists of domain names. So I'm looking for a way to use this domain array in SQL query. Maybe something like we use with SELECT. Example:
const ids = [3, 4, 6, 8];
const query = 'SELECT * FROM table WHERE id IN (' + ids.join() + ')';
Is there a way to use array for tables names in SQL? Thank you in advance!
idsarray could come from the outside, unsterilized, then you'll want to use a prepared statement to build your query.