RE: [PHP-DB] I have a query
Thanks Mr.Bastien, I was searching all over the Google,But I could not find one,May be my search was not that good one.. Thanks Mr.Bastien for helping me and saving my time. -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 29, 2004 11:45 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] I have a query if the tables have the same structure, use the union operator to query each table separately and return it all in one result set select * from asset1 where asset_loc='heaven' union select * from asset2 where asset_loc='heaven' union select * from asset3 where asset_loc='heaven' union select * from asset4 where asset_loc='heaven' union select * from asset5 where asset_loc='heaven' bastien >From: "Mulley, Nikhil" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Subject: [PHP-DB] I have a query >Date: Wed, 29 Sep 2004 23:19:31 +0530 > >I have a query regarding mysql and PHP ... >here it is >I know there is a field data exisiting in one of the tables in the present >database; > >I want to know whether there is any sql or PHP function with which I can >find out in which table the field data is present for example . > > >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) > >I want to know ,in which table among the above is having a particular field >data for example ...the column name is asset_loc ( common for all the >tables,but no constraints ,no relation with other tables) > >I want to know if the asset_loc from any table has the data 'heaven' > >it should be something like this >select * from asset1,asset2,asset3,asset4,asset5 where asset_loc='heaven'; > > > >Thanks, waiting for a quick response from a great list. > >SELECT * FROM Linux_kids where Dis_Hard_Fans='Nikhil' ;-) > > _ Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] I have a query
> 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 [EMAIL PROTECTED] 802-558-5247 For a GMail account contact me OFF-LIST -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] I have a query
Just an addendum to Bastien's post: You'll need MySql 4.0+ if you want to use UNION. > -Original Message- > From: Bastien Koert [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 29, 2004 2:15 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] I have a query > > > > if the tables have the same structure, use the union operator > to query each > table separately and return it all in one result set > > select * from asset1 where asset_loc='heaven' > union > select * from asset2 where asset_loc='heaven' > union > select * from asset3 where asset_loc='heaven' > union > select * from asset4 where asset_loc='heaven' > union > select * from asset5 where asset_loc='heaven' > > bastien > > > > > >From: "Mulley, Nikhil" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Subject: [PHP-DB] I have a query > >Date: Wed, 29 Sep 2004 23:19:31 +0530 > > > >I have a query regarding mysql and PHP ... > >here it is > >I know there is a field data exisiting in one of the tables > in the present > >database; > > > >I want to know whether there is any sql or PHP function with > which I can > >find out in which table the field data is present for example . > > > > > >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) > > > >I want to know ,in which table among the above is having a > particular field > >data for example ...the column name is asset_loc ( common > for all the > >tables,but no constraints ,no relation with other tables) > > > >I want to know if the asset_loc from any table has the data 'heaven' > > > >it should be something like this > >select * from asset1,asset2,asset3,asset4,asset5 where > asset_loc='heaven'; > > > > > > > >Thanks, waiting for a quick response from a great list. > > > >SELECT * FROM Linux_kids where Dis_Hard_Fans='Nikhil' ;-) > > > > > > _ > Take advantage of powerful junk e-mail filters built on > patented Microsoft(r) > SmartScreen Technology. > http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&; > DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > Start enjoying all the benefits of MSN(r) Premium right now > and get the > first two months FREE*. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] I have a query
if the tables have the same structure, use the union operator to query each table separately and return it all in one result set select * from asset1 where asset_loc='heaven' union select * from asset2 where asset_loc='heaven' union select * from asset3 where asset_loc='heaven' union select * from asset4 where asset_loc='heaven' union select * from asset5 where asset_loc='heaven' bastien From: "Mulley, Nikhil" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: [PHP-DB] I have a query Date: Wed, 29 Sep 2004 23:19:31 +0530 I have a query regarding mysql and PHP ... here it is I know there is a field data exisiting in one of the tables in the present database; I want to know whether there is any sql or PHP function with which I can find out in which table the field data is present for example . 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) I want to know ,in which table among the above is having a particular field data for example ...the column name is asset_loc ( common for all the tables,but no constraints ,no relation with other tables) I want to know if the asset_loc from any table has the data 'heaven' it should be something like this select * from asset1,asset2,asset3,asset4,asset5 where asset_loc='heaven'; Thanks, waiting for a quick response from a great list. SELECT * FROM Linux_kids where Dis_Hard_Fans='Nikhil' ;-) _ Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] I have a query
I have a query regarding mysql and PHP ... here it is I know there is a field data exisiting in one of the tables in the present database; I want to know whether there is any sql or PHP function with which I can find out in which table the field data is present for example . 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) I want to know ,in which table among the above is having a particular field data for example ...the column name is asset_loc ( common for all the tables,but no constraints ,no relation with other tables) I want to know if the asset_loc from any table has the data 'heaven' it should be something like this select * from asset1,asset2,asset3,asset4,asset5 where asset_loc='heaven'; Thanks, waiting for a quick response from a great list. SELECT * FROM Linux_kids where Dis_Hard_Fans='Nikhil' ;-)