AW: [PHP-DB] Order by multiple tables

From: Date: Tue, 08 Aug 2000 11:05:45 +0000
Subject: AW: [PHP-DB] Order by multiple tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-1847@lists.php.net to get a copy of this message
Ok! Thanks for all your help. But I think I am not making myself clear - it may also be that I don't underdtand you. I am trying to give you an example: I have two tables. Let's call them "videorecorders" and "televisions". I want to select all videorecorders and televisions and order them by their price. So that I get a result like this: videorecorder1 $500 television1 $399 television2 $250 videorecorder2 $101 As you can imagine, it is not possible to put the videorecorders and televisions in one table, because they may all have a price and a name, but a television compared to a videorecorder may have a screen size or something else. Hopefully you understand what I wanna do now. Thanks for your friendly answers. mfG Simon Biela > -----Ursprüngliche Nachricht----- > Von: Tigger-oN [mailto:tigger@ebom.org] > Gesendet: Dienstag, 8. August 2000 00:41 > An: php-db@lists.php.net > Betreff: RE: [PHP-DB] Order by multiple tables > > > another example > mods_list is a table that contains lots of info about *mods* > mods_login is a table that contains login info like user > name and password > > SELECT > mods_list.id AS id > mods_login.name AS author > mods_login.email AS author_email > FROM mods_list INNER JOIN > mods_login ON > mods_list.id_login = mods_login.id > WHERE mods_login.active = 1 and mods_list.active = 1 > ORDER BY mods_list.datestamp DESC" > > > for a great SQL sample page try > http://w3.one.net/~jhoffman/sqltut.htm > > hope that helps > > Tigger-oN > > > > -----Original Message----- > > From: Sam Masiello [mailto:smasiello@chekinc.com] > > Sent: Monday, 7 August 2000 11:47 PM > > To: Simon Biela; php-db@lists.php.net > > Subject: RE: [PHP-DB] Order by multiple tables > > > > > > > > You need to join the tables based on a commonality between them. > > Otherwise, > > you will get a cross-product between the two tables. Like this: > > > > SELECT <whatever> > > FROM table1, table2 > > WHERE table1.value=table2.value > > > > HTH > > > > Sam Masiello > > System Analyst > > Chek.Com > > (716) 853-1362 x289 > > smasiello@chekinc.com > > > > -----Original Message----- > > From: Simon Biela [mailto:s.biela@netdienste.de] > > Sent: Monday, August 07, 2000 9:50 AM > > To: Sam Masiello; Simon Biela; php-db@lists.php.net > > Subject: AW: [PHP-DB] Order by multiple tables > > > > Hi again! > > > > I don't know what I am doing wrong, but I get the following error: > > > > In table1, there are 10 entries. In table2 I can find 7 entries. > > As soon as > > I say: > > SELECT * FROM table1, table2 > > > > MySQL returns 70 results. Is that right? > > > > mfG > > Simon > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#1847) next »