I don't get results using 'WHERE' and 'AND'

Hello experts
I have a table Artextras
Artikel_ID     Extras
      253           10
      256           20
      264           20
      264          10
      264          40
      264          50
      264          60

And when i run the query:
FROM Artextras
WHERE Extras = 10
 AND Extras = 20
i don't get any results.I must get the Artikel_id 264 as result .where is the mistake?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you shoudln't be using AND...use OR

FROM Artextras
WHERE Extras IN (10, 20)
you don't have a result since no rows have a extras=20 and extras=10
you want this

select t1.artikel_id
from Artextras t1 inner join Artextras t2 on t1.artikel_id = t2.artikel_id
where t1.Extras = 10
and t2.Extras = 20

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
logically...AND would never work here on the same field.  One field can never have 2 specific values (for the same "cell")
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Kevin CrossChief Technology OfficerCommented:
The answers above are correct --- this is an alternative to get what I think you are after.

You want to select id that has a record for 10 and for 20 and only those ids that do.

SELECT artikel_id
FROM Artextras a
WHERE extras = 10 AND EXISTS (SELECT 1 FROM Artextras b WHERE a.artikel_id = b.artikel_id AND extras = 20)

FROM Artextras
WHERE Extras = 10 OR Extras = 20

FROM Artextras
WHERE Extras = 10
 AND Extras = 20

will not return any results because no field Extras is both 10 and 20. You have to use OR:

FROM Artextras
WHERE Extras = 10 OR Extras = 20

this will return

 253           10
      256           20
      264           20
      264          10

PanosAuthor Commented:
Hi to all of you.
Thank you for your help.
looking at the question .....I must get the Artikel_id 264 as result .where is the mistake?......
i think that mwvisa1 and momi_sabag have found the way to get only 264 as result.
Now i will make a new question where these two numbers are not always the same but a variable.
Please help me with that too.
PanosAuthor Commented:
Thank you again for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.