Thread: MySQL Query
View Single Post
  #1  
Old 3rd Jan 06, 06:31 AM
*MO*'s Avatar
*MO* *MO* is offline
Senior Member
 
Join Date: Aug 2002
Location: Cape Town
Posts: 311
*MO* is an unknown quantity at this point
Send a message via MSN to *MO*
MySQL Query
Hi Everyone. I've got a problem with an SQL query. I'm gonna try my best to explain the structure and the problem i'm having.

I've got 2 tables. one is called 'articles', and the other is called 'sections'
the articles table has a foreign key called sectionsID which will be the same as the secions.id.

Now the sections table also has a field that specifies if the section is hidden or not. field is called sections.hidden and is an enum of 'Y', and 'N'.

so i can say :
SELECT articles.* FROM articles,sections WHERE sections.hidden = 'N'

easy

but the articles.sectionID can store more than one sections ID. ie: 3-4
which means, that this article is in section 3 and section 4.

however, section 3 is hidden. 4 is NOT hidden.

but when i do a query to show all articles, i want it show this article, even tho its in 3 and is hidden, but because its in 4, it will be visible.
if it was JUST in section 3, then it would not show.

If its gonna make is easier, this is for a blog system. so you can understand what i'm trying to do.

Any help would really be great. Thank you
Reply With Quote