Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

we have a table called transaction_details. when i write this query

SELECT 
DESCRIPTION,
item,
cust_code,
pack_description,
uos,
pack,
total_value,
total_value_vat,
total_value_goods,
price_indicator
from TRANSACTION_DETAILS
where cust_code=1273 
and item =371355
and item =371476
and item =371629
and item =370556
and item =370677
and item =370820
and item =370952
and item =371070
and item =371223
and item =372154
and item =372253
and item =371751
and item =371872

it shows me nothing in the result pane. we want to see the reult of these all the item one by one in single line of each item and dont want to be duplicate. thanks for helping.

share|improve this question

closed as off topic by Martin Smith, Jack Douglas Apr 6 '12 at 19:50

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

8  
I suspect you'll want to be using OR instead of AND. en.wikipedia.org/wiki/Boolean_algebra –  Phil Apr 4 '12 at 9:34
    
This is too basic for dba.se - ask on SO instead? –  Jack Douglas Apr 6 '12 at 19:50
    
It seems the operator you require is relational division, commonly known as 'the supplier who supplies all parts'. Follow that link to Stack Overflow, then follow the 'relational-division' tag to view similar questions and possible solutions. –  onedaywhen Apr 10 '12 at 9:22

1 Answer 1

SELECT 
DESCRIPTION,
item,
cust_code,
pack_description,
uos,
pack,
total_value,
total_value_vat,
total_value_goods,
price_indicator
from TRANSACTION_DETAILS
where cust_code=1273 
and item in
(
    371355,
    371476,
    371629,
    370556,
    370677,
    370820,
    370952,
    371070,
    371223,
    372154,
    372253,
    371751,
    371872
)

As for duplicates, you're going to have to decide how you want duplicates handled. Using a GROUP BY, if there is a duplicate item you will have to figure out how to aggregate the rest of the data for the result set. Feel free to give me that info and I can write up your aggregate query.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.