Re: I have a query

From: Date: Wed, 29 Sep 2004 18:21:31 +0000
Subject: Re: I have a query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-36453@lists.php.net to get a copy of this message
> I have database called asset > in which 5 table are present namely asset1,asset2,asset3,asset4,asset5... > > all the tables have the same schema structure and common field names ,equal no of columns(but > not the equal number of rows) why on earth would you do this? rather i would create a database named site or something and a table called asset_groups, here i would have id (int 11 auto_increment primary_key) title (varchar 50) this is where i would store Asset1, Asset2 etc... i would then have a table called assets and have that be sturectured like so id (int 11 auto_increment primary_key) asset (int 11) (ID of the asset_group) whatever else you want for column names. $result = mysql_query("SELECT id, title FROM asset_groups as ag INNER JOIN assets a ON ag.id=a.asset WHERE a.asset_loc='heaven'"); while($data=mysql_fetch_array($result)) { // returned a row, display it or whatever } $result = null; $data = null; this would return a row containing everything you want and would allow you to loop through the rows so you can display them or whatever -- Joseph Crawford Jr. Codebowl Solutions codebowl@gmail.com 802-558-5247 For a GMail account contact me OFF-LIST

« previous php.db (#36453) next »