Re: mySQL 'multiple' SELECT

From: Date: Wed, 06 Dec 2000 04:12:13 +0000
Subject: Re: mySQL 'multiple' SELECT
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28843@lists.php.net to get a copy of this message
That all seems pretty odd for the table setup... Are you sure you need four tables with usernames and a field to relate to another table called users?... If so, it seems like you need a UNION clause for one case, and a sub-select for the other, neither of which MySQL supports, so no, there is no better way to do that in MySQL, without re-designing your table schema... If you *need* this, you may want to consider PostgreSQL (http://postgresql.org) which is OpenSource and supports both those constructs (and lots more) but is still pretty darned fast, especially if you take the time to analyze and optimize your complex SQL. My first guess, though, is still that your database schema needs re-designing... ----- Original Message ----- From: Maxim Maletsky <maxim.maletsky@japaninc.net> Newsgroups: php.general Sent: Tuesday, December 05, 2000 9:10 PM Subject: [PHP] mySQL 'multiple' SELECT > Hello, > > I have a very simple question: > > I've got 4 tables. > (table1, table2, table3, table4) > Each of them is having a field called 'user' containing the 'id' of another > fifth table called 'users'. > > The reason for it is to being able browsing any of the table(1-4) and search > for the user with something like: > > SELECT user FROM $table WHERE id='$id'; { > SELECT * FROM users where id=$result_of_above; > } > > Now, is there any simpler way to do it? I would like it to be in one single > statement. > > > > And, how can I do vice versa? > > SELECT id FROM users WHERE field='value'; > > and then find which of the 4 tables contains field 'user' equal to the > result of above. > > Thanks in advance. > Maxim Maletsky. > > Maxim Maletsky - maxim@j-door.com > <mailto:maxim@j-door.com> > Webmaster, J-Door.com / J@pan Inc. > LINC Media, Inc. > TEL: 03-3499-2175 x 1271 > FAX: 03-3499-3109 > > http://www.j-door.com <Ž[­U"¦óé3 > ~óá••http://www.j-door.com/> > http://www.japaninc.net > <http://www.japaninc.net/> > http://www.lincmedia.co.jp > <http://www.lincmedia.co.jp/> > > > > > ---------------------------------------------------------------------------- ---- > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#28843) next »