RE: [PHP-DB] Difficult query ?
| From: | Disser, Arno | Date: | Mon, 16 Oct 2000 09:23:17 +0000 |
| Subject: | RE: [PHP-DB] Difficult query ? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-3630@lists.php.net to get a copy of this message | ||
Not to difficult, bu you need to reconsider your datamodel first.
Define a table MOVIES, in wich you do insert your movie titles.
Define a table ACTORS, in wich you do insert your actors.
Define a table ACTSIN, in wich you insert the films and it's actors.
(example in pseudo code:
Define tables:
ACTORS(id,name)
MOVIES(id,name)
ACTSIN(id.movies_id,actors_id)
Required query:
select movie.name
from ACTORS,
MOVIES,
ACTSIN
where ACTSIN.movies_id = MOVIES.id and
ACTSIN.actors_id = ACTORS.id and
ACTORS.name = 'Any given variable';
As you see, you get more a flexible data structure.
(B.T.W. This method is called Normalisation, and works fine on any kind of
database!)
------------------------------------------------
Arno Disser
SFS/Pensioenen en Verzekeringen
FAD/ICT
Postbus 11
2280 AA RIJSWIJK The Netherlands
Tel +31 (0)70 33 66 389
Fax +31 (0)70 31 93 884
email: <mailto:disser_a@sfs.nl>
------------------------------------------------
-----Oorspronkelijk bericht-----
Van: Jeroen ten Berge [mailto:j.ten.berge@getexo.nl]
Verzonden: zaterdag 14 oktober 2000 19:33
Aan: PHP Database
Onderwerp: [PHP-DB] Difficult query ?
Hi, I have 1 table with the rows Actor1,Actor2,Actor3 and title;
What I want is 1 select box where you can type the actor and then get a list
of the movies this actor is in...
Anybody ideas ?
--
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