filter fodder: sql, query

Hi,

Hope someone can help with this.

I have a table subjects:
 qsid  smallint ...
 name varchar(60)

The table contains eg.
Mathematics
English
Biology
... ...

I also have a table vx_students:
  vxid smallint ...
  pri_qskey smallint not null default 0
  sec_subj smallint not null default 0
  ter_subj smallint not null default 0

A common entry into vx_students might be:
mysql> select * from vx_students where vxid = 1;
+------+------------+-----------+-----------+-----------+
| vxid | studentkey | pri_qskey | sec_qskey | ter_qskey |
+------+------------+-----------+-----------+-----------+
|    1 |       1507 |       124 |         77 |         0 |
+------+------------+-----------+-----------+-----------+

The two problems:

(a) I can't figure out how to construct the query to get ALL the subject 
names.  To just get one, this works:
select vxid, subjects.name
from vx_students, subjects
where vx_students.pri_qskey=subjects.qsid
and vx_students.studentkey=1;

(b) I can't figure out how to construct the query to skip if 
eg. ter_qskey == 0 
(although pri_qskey || sec_qskey || ter_qskey could be 0 ).

Here's hoping some whizz out there knows the answers.

Donna





---------------------------------------------------------------------
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