Hello everyone, I need some help writing this query. I got a DB with 9 user tables (one for usernames starting with a,b,c, another for d,e,f, and so on). The fields are -basically- Username and Update Date. I also have a tenth table which stores the usernames of a given user's FRIENDS. Now, I have to run a query to display a given user's (call him user A) FRIENDS, ordered by "update date" of those friends .... meaning I have to check which users were added as friends by user A, and then get their respective "update date" from one of the 9 tables according to their name. (if user A has two friends: one starting with letter 'a' and another with 'd', i'd have to check both abc and def tables to see which one of them has the most recent update date...) Any way ... I can't pull this join together Please help ! thanks in advance
Thats probably the worst db design i've heard of for a long time I'd recommend redesigning the database, cause now it's not bad - it's very bad. How many users do you expect to have and how did you come with the idea of making 10 tables where 2 are sufficient ?
I agree with xlcho. 10 tables?! Are you out of your mind? :S I mean, you need just 2 tables for that: user and friends. Redesign your databases, man.
Why are you using multiple tables? Unless you have a HUGE number of records (in millions), I don't see a reason to partition your tables.
ok hehe I have to agree here what the heck do you have 9 user tables for? Trying to make yourself go nuts or something? You could use multiple joins but damn would that be insane if that database ever got to any size at all...Your queries would become so complex it would be unmanageable... Redeisgn it before you get to far into it. Thats just insane there...