Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with a SQL Query

Guest
Oct 30, 2009 Oct 30, 2009

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

TOPICS
Database access
803
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 30, 2009 Oct 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 31, 2009 Oct 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 30, 2009 Oct 30, 2009

This

EVALUATIONS

id | idwebsite | idevaluator

looks incomplete.  Where is the field with the evaluation?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 30, 2009 Oct 30, 2009

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

To semplificate use these tables and fields:
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 31, 2009 Oct 31, 2009
LATEST

Exactly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources