Re: Whats the Query
| From: | Ted Rolle | Date: | Mon, 06 Nov 2000 06:08:48 +0000 |
| Subject: | Re: Whats the Query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4226@lists.php.net to get a copy of this message | ||
On Mon, 6 Nov 2000, Leonard Tambunan wrote:
>
> Hi All
>
> This is not bout php. :-))
> This is about SQL.
>
> I have three tables,
>
> Table1: Table2: Table3:
> -------- ---------- ---------
> nip nip class
> name class topic
>
>
> I am a teacher with name='Leonard' ( in table1).
> I wan to query all the topics (table3.topic) I have.
> What is the statement?
SELECT t3.topic
FROM Table1 t1, Table2 t2, Table3 t3
WHERE t1.name="Leonard"
AND t2.nip=t1.nip
AND t3.class=t2.class
Start with this. You might get no result; it may be too restrictive.
If this doesn't give you the correct result, remove t3.class=t2.class;
If it STILL isn't right remove t2.nip=t1.nip, but I think this will be too
permissive. But then, the query might give you the correct result on the
first try... ;->
Ted