Panos
asked on
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:
SELECT *
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?
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:
SELECT *
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
logically...AND would never work here on the same field. One field can never have 2 specific values (for the same "cell")
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT *
FROM Artextras
WHERE Extras = 10 OR Extras = 20
FROM Artextras
WHERE Extras = 10 OR Extras = 20
SELECT *
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:
SELECT *
FROM Artextras
WHERE Extras = 10 OR Extras = 20
this will return
253 10
256 20
264 20
264 10
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:
SELECT *
FROM Artextras
WHERE Extras = 10 OR Extras = 20
this will return
253 10
256 20
264 20
264 10
ASKER
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.
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.
ASKER
Thank you again for your help.
Regards
Panos
Regards
Panos
SELECT *
FROM Artextras
WHERE Extras IN (10, 20)