Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: (OT) MySQL Help

by UnderMine (Friar)
on Jun 13, 2006 at 05:48 UTC ( [id://554956]=note: print w/replies, xml ) Need Help??


in reply to (OT) MySQL Help

Because MySQL does not support dynamic SQL you have to write perl to wrap the required SQL. The INFORMATION_SCHEMA TABLES Table contains the info you need to generate the SQL.

The initial SQL would look like this :-

SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name'
Or you could use table_info on your database handle if you don't need to limit the returned list of tables or are going to filter it in perl.

The second dynamic SQL statement would look like :-

$sql = join ' UNION ', map "SELECT ID, Name, Class, Mark, $_ table_na +me from $_", @tables;
Hope it help
UnderMine

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://554956]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found