MySQL Forums
Forum List  »  General

Subquery referencing DB name in FROM
Posted by: David Lage
Date: June 15, 2007 12:25PM

SELECT DISTINCT table1.`table`
FROM (

SELECT concat( 'db_', vsc.stat_db_id, '.music_song_play_day_summary' ) AS `table`
FROM db.stat_controller AS vsc
WHERE vsc.table_prefix = 'music_song_play'
AND vsc.type = 'active'
) AS table1

Basicly this returns

table
'db_1.music_song_play_day_summary'

SELECT table2. *
FROM (

SELECT DISTINCT table1.`table`
FROM (

SELECT concat( 'db_', vsc.stat_db_id, '.music_song_play_day_summary' ) AS `table`
FROM db.stat_controller AS vsc
WHERE vsc.table_prefix = 'music_song_play'
AND vsc.type = 'active'
) AS table1
) AS table2

And this returns the same thing

table
'db_1.music_song_play_day_summary'

And keeps doing it for as long as i keep subquering. Is this a bug?

I have db's like the following...

db

db_1
db_2
db_3

Options: ReplyQuote


Subject
Written By
Posted
Subquery referencing DB name in FROM
June 15, 2007 12:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.