Jump to content


Photo

I'm trying something


  • Please log in to reply
6 replies to this topic

#1 geus

geus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 January 2003 - 04:48 PM

I have one table with users and for each user a table with a list of 8 names.

Is there a possibility to make a select from - and then an array or something to call all tables with the names in the users table

Or am I trying something that isn\'t possible ?

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 28 January 2003 - 07:24 PM

loop through the first query\'s results and assemble another query string; then execute that one. i\'m not sure i fully understood what you\'re trying to do... can you use a join? :shock:

something like this?

http://forums.phpfre...opic.php?t=1644
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 geus

geus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 January 2003 - 09:12 PM

Not exactly.

I want to collect data from other tables with the names of the users in my users table.

But I don\'t want to adjust the script each time a user is added so is it possible that it calls all tables with the names of the users in the user table.

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 28 January 2003 - 11:49 PM

this would be possible using that loop syntax.

for example:

select * from users
would return: bill, bob, joe

this will return the names in the users table even if it is updated. then use that array to make whatever you need.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 29 January 2003 - 12:24 PM

I have one table with users and for each user a table with a list of 8 names.

Is there a possibility to make a select from - and then an array or something to call all tables with the names in the users table

Or am I trying something that isn\'t possible ?


Basically this is not the best design.

Make two tables:

1. Having the usernames called users
2. Having the 8 names and the username

Like

A:
Billy
Bob
Thornton

B:
Billy Donald
Billy Duck
Billy Palle
Bob Bush
Bob Sadam
and so on...

To get Billys friends...

select * from a left outer join b on a.user = b.user where a.user=\'Billy\';

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#6 geus

geus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 29 January 2003 - 12:33 PM

No it\'s something else.

I have one table wit users and their data.

Then I have for each user a table where they can store data for their own.

so
table users
user1
user2
user3

and then i have tables called user1, user2, user3

I want to collect all data for example
select * from user1
select * from user2
and so on

#7 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 29 January 2003 - 01:18 PM

Ok, but if the design of table user1 and user2 and so on are identical, i.e. same number of coloumns, format etc. then it\'s a lot better to make one big table to hold this information.
Then just make a single coloumn identifying the \"owner\" of the current row (the username).

Otherwise you could quickly end up having a lot of tables, and you would need to allow create table permissions to your scripts.

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users