For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > September 2004 > Re: [PHP-DB] I have a query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] I have a query
Joseph Crawford

2004-09-29, 8:03 pm

> 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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com