In the simplest case, LanguageSkill and City are columns in the Persons
table. (That's the wrong way to do, IMO, but it is the simplest case.)
Suppose Language Skill is an integer column and City a char(50).

So your query becomes:

SELECT *
FROM Persons
WHERE LanguageSkill = 5
AND City = 'London';

The more complicated answer presupposes that you have normalized the tables

Persons - fairly obvious, PK is PersonID, with a CityID integer column
referencing the table Cities
Languages - PK is LanguageID integer, languagename char(30)
PersonLanguages - n rows for every person who speaks a language. FKs
PersonID and LanguageID, with a tinyint or ENUM column for SkillLevel.
Cities - PK is CityID

Now you need to join the four tables to get your answer:

SELECT *
FROM Persons
INNER JOIN PersonLanguages ON Persons.PersonID = PersonLanguages.PersonID
INNER JOIN Languages on PersonLanguages.LanguageID = Languages.LanguageID
INNER JOIN Cities ON Persons.CityID = Cities.CityID
WHERE Languages.Language = 'English'
AND PersonLanguages.SkillLevel = 5
AND Cities.CityName = 'London';

I find that a good way to build such queries for PHP is first get everything
right in myCC or MySQL-Front etc., and then to paste the query into the php
script. After that, it's simple to massage it into an appropriate statement.
If you begin with a standard php template, most of the work is already done
for you.

hth,
Arthur

----- Original Message -----
From: "Eve" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, April 28, 2002 3:48 PM
Subject: Php query from sql


> Hello everybody,
>
> I'm quite new with all this php mysql "cooperation thing" but somehow I
> already managed to set up mysql database and I'm able to also make
> query's based on any keyword...
> Now I wonder how to add to this basic query also option to select some
> concrete data.
>
> For example in the database I have section Languages, where people can
> choose is their English laguage skill 'poor', 'good', 'very good'. Now I
> would like to add to the general query additional field where it could
> be possible to select only data of persons with very good English
> language skills. For example I would like to be displayed only persons
> who are living in London (this will be keyword) and are speaking English
> very well...
>
> Please can anyone help me?
>
> Best regards,
> Eva
>
>
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to