Table selection
am 03.03.2004 15:40:06 von Marco Bresciani
Hello all,
I have a little problem to solve.
I have a "List" table that lists the tables contained in the same DB. This
table has a "Name" filed that contains such names.
My problem is that the list.name filed doesn't contain the complete name of
the tables but it misses a "prestring". Say: a table is named "FXnnnn" but
the list.name field contains "nnnn" only.
I have to create a query like:
SELECT * FROM [every table in list.name] WHERE [condition]
but I cannot use "SELECT Name FROM List" to gain the names of the tables
because they all miss the "FX" string.
How can I create this kind of query? Something like:
SELECT * FROM ("FX" + SELECT Name FROM List) WHERE [condition]
I hope I was clear 'cause my English is not so good. Is there anyone who
can help me?
Thank you!
Marco Bresciani
--
(o> Utente SETI@Home da 3,632 anni (2200 unità )
//\ Tempo CPU: 2,238 anni (8h 54min 44s medio)
V_/_ Posizione: 111701/4900443 (97,72%)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org
Re: Table selection
am 03.03.2004 15:58:44 von Egor Egorov
"Marco Bresciani" wrote:
> Hello all,
> I have a little problem to solve.
> I have a "List" table that lists the tables contained in the same DB. This
> table has a "Name" filed that contains such names.
>
> My problem is that the list.name filed doesn't contain the complete name of
> the tables but it misses a "prestring". Say: a table is named "FXnnnn" but
> the list.name field contains "nnnn" only.
>
> I have to create a query like:
>
> SELECT * FROM [every table in list.name] WHERE [condition]
>
> but I cannot use "SELECT Name FROM List" to gain the names of the tables
> because they all miss the "FX" string.
>
> How can I create this kind of query? Something like:
>
> SELECT * FROM ("FX" + SELECT Name FROM List) WHERE [condition]
>
You can't do it only with MySQL. Retrieve table names from List table:
SELECT CONCAT("FX", Name) FROM List;
and then use programming language to construct a query.
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Egor Egorov
/ /|_/ / // /\ \/ /_/ / /__ Egor.Egorov@ensita.net
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
<___/ www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org
Re: Table selection
am 03.03.2004 16:11:27 von Marco Bresciani
Egor Egorov ha scritto:
>You can't do it only with MySQL. Retrieve table names from List table:
> SELECT CONCAT("FX", Name) FROM List;
>
>and then use programming language to construct a query.
Thank you... I've supposed it...
What about using UNION? Something like:
SELECT * FROM FX5686 UNION SELECT * FROM FX5698 UNION ... WHERE [condition]
I obviously need a programming language to compose this query... but it
seems clearer to me... if it works!
Marco Bresciani
--
(o> Utente SETI@Home da 3,632 anni (2200 unità )
//\ Tempo CPU: 2,238 anni (8h 54min 44s medio)
V_/_ Posizione: 111701/4900443 (97,72%)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org
Re: Table selection
am 03.03.2004 16:52:52 von Egor Egorov
"Marco Bresciani" wrote:
> Egor Egorov ha scritto:
>
>>You can't do it only with MySQL. Retrieve table names from List table:
>> SELECT CONCAT("FX", Name) FROM List;
>>
>>and then use programming language to construct a query.
>
> Thank you... I've supposed it...
> What about using UNION? Something like:
>
> SELECT * FROM FX5686 UNION SELECT * FROM FX5698 UNION ... WHERE [condition]
>
> I obviously need a programming language to compose this query... but it
> seems clearer to me... if it works!
You can use UNION, but WHERE condition should be written for each SELECT in the UNION:
(SELECT * FROM FX5686 WHERE ..) UNION (SELECT * FROM FX5698 WHERE .. ) ..
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Egor Egorov
/ /|_/ / // /\ \/ /_/ / /__ Egor.Egorov@ensita.net
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
<___/ www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org