MySQL Forums
Forum List  »  Newbie

An interesting problem to solve or to decide to be unsolvable
Posted by: jluoma
Date: August 19, 2005 05:01AM

I have a table "foo" that looks like following
foo {
sID varchar(29),
year varchar(4),
foobar varchar(10)
}

usually it contains lines like:
092384 0004 bebob
120926 0105 babu

Then I have tables "op0004daa" and "op0105daa" . These tables contain additional information for "foo" table. It is easy to select more information for table "foo" in e.g. PHP, but can this be done in MySQL? I tried FROM subqueries without success.

The "year" column in "foo" table contains part of the table name in which rest of the information resides. When I want to see rest of the information I will first get info from "foo" table and save it to variables in PHP and then generate select statements that point to right table (e.g. first line contains "0004" value for "year" column, then I would select rest of the information from table "op0004daa".

Following line is what I tried without success (it did not return rows from table "op0004daa")

select * from (select concat('op',year,'daa') from foo where sID = "092384") as sumthing;

Question: can this be done without external programming language, in MySQL?

regards,
Jamal

Options: ReplyQuote


Subject
Written By
Posted
An interesting problem to solve or to decide to be unsolvable
August 19, 2005 05:01AM


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.