Re: mySQL 'multiple' SELECT

From: Date: Wed, 06 Dec 2000 05:15:45 +0000
Subject: Re: mySQL 'multiple' SELECT
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-28848@lists.php.net to get a copy of this message
> > 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. I do something similiar in one of my sites. I have four tables that contain specific information about a company listed in a business table that has all the company static info. I can query the database and ask for all the bisinesses that have "something" in a field on table one and return the information about the business from the main table. I use a JOIN in mysql. Read a little about it in a mysql book. SELECT from table1, users where table1.field="something" and users.id=table1.id; I would really suggest reading a book on mysql and sql for reference to gain a better understanding. If you like email me offlist and I will send an example of how I select information from several tables in MySQL. Brett

« previous php.general (#28848) next »