Skip to main content
October 30, 2009
Question

Help with a SQL Query

  • October 30, 2009
  • 2 replies
  • 842 views

Hi,

I have three tables:

1) a table (WEBSITES) where I store the "urls" of websites I want to evaluate.

2) a table (EVALUATIONS) where I store "evalutations" (this website is good, this is bad ...) of each website.

3) a table (EVALUATORS) where I store the "evaluators".

I want to create a query that pick the first website's url that the evaluator X has not evaluate yet.

To semplificate use these tables and fields:

WEBSITES

id | url

EVALUATORS

id | evaluator

EVALUATIONS

id | idwebsite | idevaluator

Could you build for me a query that work? I tried but I'm not so good as I thought ...

Thanks in advance for you help.

GiBi

This topic has been closed for replies.

2 replies

Inspiring
October 30, 2009

This

EVALUATIONS

id | idwebsite | idevaluator

looks incomplete.  Where is the field with the evaluation?

ilssac
Inspiring
October 30, 2009

I presumed it was left out of the post from this line.

To semplificate use these tables and fields:
October 31, 2009

Exactly.

ilssac
Inspiring
October 30, 2009

SELECT MIN(ID), URL

FROM WEBSITES

WHERE ID NOT IN (SELECT IDWEBSITE FROM EVALUTATIONS WHERE IDEVALUATOR = 13)

GROUP BY ID, URL

Is that close?

October 31, 2009

Yes, very close, thanks a lot.

I was able to work it out with this query:

SELECT TOP 1 ID
FROM WEBSITES
WHERE ID NOT IN (SELECT ID FROM EVALUATIONS WHERE IDEVALUATORS = 1)