Learn, Share, Build

216
September 20, 2017, at 1:37 PM

can I use the result of query (Query 1) as a table name into anothers query? Example. Query 1.

SELECT table_name
FROM information_schema.tables
WHERE table_type='BASE TABLE' AND 
table_schema='schemaName' AND table_name LIKE '%_assoc_device'

I would like to use every single query just written, like table name, to build new queries.

SELECT * FROM (Query 1 Result)

This query for each result. With this automatic method, I would like to create a view

Answer 1

I Try to use this set of command, but must limit the result to 1

SET @sql := CONCAT(
'SELECT * 
 FROM ', (SELECT table_name 
         FROM information_schema.tables 
         WHERE table_type='BASE TABLE' 
         AND table_schema='schemaName'
         AND table_name LIKE '%_assoc_device' LIMIT 1)
 );
 PREPARE s FROM @sql;
 EXECUTE s;
 DEALLOCATE PREPARE s;

Can I Extends this concept, to all result of subquery?

Rent Charter Buses Company
READ ALSO
Learn, Share, Build

Learn, Share, Build

A lost update occurs when two different transactions are trying to update the same column on the same row within a database at the same timeTypically, one transaction updates a particular column in a particular row, while another that began very shortly...

228
Learn, Share, Build

Learn, Share, Build

My Data look like :

256
Learn, Share, Build

Learn, Share, Build

I made a platform to remind me of some things I haven't doneI've stored this reminds into a database and now I want this PHP based Website to send me emails

212