geus Posted January 28, 2003 Share Posted January 28, 2003 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 ? Quote Link to comment Share on other sites More sharing options...
effigy Posted January 28, 2003 Share Posted January 28, 2003 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.phpfreaks.com/viewtopic.php?t=1644 Quote Link to comment Share on other sites More sharing options...
geus Posted January 28, 2003 Author Share Posted January 28, 2003 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. Quote Link to comment Share on other sites More sharing options...
effigy Posted January 28, 2003 Share Posted January 28, 2003 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. Quote Link to comment Share on other sites More sharing options...
pallevillesen Posted January 29, 2003 Share Posted January 29, 2003 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. Quote Link to comment Share on other sites More sharing options...
geus Posted January 29, 2003 Author Share Posted January 29, 2003 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 Quote Link to comment Share on other sites More sharing options...
pallevillesen Posted January 29, 2003 Share Posted January 29, 2003 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.