flyingfrog
11-20-2008, 01:25 PM
I have two tables:
Table Essays: (Primary Key) ID, Title, Author,Abstract, file location
Table Subjects: (Foriegn key) ID, section
An essay (in Table Essays) may be in more then one section. Hence no primary key in Table Subjects. Only a foreign key (tho I cant see a way of defining it as such).
Also I've written the following search (which works) but are there any obvious flaws with it.
SELECT * FROM essays
where ID IN
(SELECT ID FROM subject
WHERE section LIKE 'Biology'
)
This filters all the (essay) ID numbers from Table Subject where the field section = Biology, Then I filter all the records from the essays table whose ID
numbers matches the above filter.
Seems to work on a very sample I've tried. Any feedback.
Thanks
Table Essays: (Primary Key) ID, Title, Author,Abstract, file location
Table Subjects: (Foriegn key) ID, section
An essay (in Table Essays) may be in more then one section. Hence no primary key in Table Subjects. Only a foreign key (tho I cant see a way of defining it as such).
Also I've written the following search (which works) but are there any obvious flaws with it.
SELECT * FROM essays
where ID IN
(SELECT ID FROM subject
WHERE section LIKE 'Biology'
)
This filters all the (essay) ID numbers from Table Subject where the field section = Biology, Then I filter all the records from the essays table whose ID
numbers matches the above filter.
Seems to work on a very sample I've tried. Any feedback.
Thanks