Results 1 to 14 of 14
Thread: SQL query...
Oct 4, 2001, 05:22 #1
- Join Date
- Feb 2000
- 0 Post(s)
- 0 Thread(s)
Having a bit of trouble with the SQL query/logic. It *should* be simple
I have a table of articles and a table of related articles. Now i am calling a "edit related articles page" and what it should do is list all the articles with a checkbox next to them. Ok, that is all fine. What i want however is for the checkbox to be selected if there is this article is already marked as "related."
The tables are:
articles (where name, id) are needed
where it has
So at the moment i am just doing
$db->query("SELECT title,id FROM article WHERE id != '$article_id'");
and looping through.
but what i need is some sort of JOIN (i think) that checks the other table first. I am not getting far at this, all the joins I am doing are resulting in the list of the articles more than once if they are also related to other articles (ie the ones we are not dealing with).
The only easy solution for me at the moment is just doing a 2nd SQL query on each article returned but that is far from optimim.