Guest_imported
New member
- Jan 1, 1970
- 0
I have a databese with two tables, magazines and departments. The magazines table has a SET type field called mag_dep with the following parameters('ADV', 'COM', 'ART'). I'm using this to link to dept.ID (primary key) in the departments table. A record can have multiple entries in mag_dep. I need to create a select statement on this database that will list all of the magazines that are associated with a department.
This is one of the SQL statements I've tried:
SELECT mag_title, mag_url, dept_name
from departments, titles
WHERE FIND_IN_SET('COM',mag_dep)
AND titles.depts = departments.dept_ID
This will only return magazine titles that have "COM" in the mag_dep set, but not if it has a multiple entry, such as "ADV,COM". I've tried altering this a bit, but haven't found anything that works.
I'm very new at all this and amy be going about it all wrong. Any help is greatly appreciated!
This is one of the SQL statements I've tried:
SELECT mag_title, mag_url, dept_name
from departments, titles
WHERE FIND_IN_SET('COM',mag_dep)
AND titles.depts = departments.dept_ID
This will only return magazine titles that have "COM" in the mag_dep set, but not if it has a multiple entry, such as "ADV,COM". I've tried altering this a bit, but haven't found anything that works.
I'm very new at all this and amy be going about it all wrong. Any help is greatly appreciated!