467,134 Members | 918 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.


Hi I need some help please

I have several custom fields in a table and want to retrieve the records that match maybe two or three or four of these customised fields.

I have written the query as follows:
SELECT T0.[ItemCode], T0.[ItemName], T0.[U_Brand], T0.[U_BrandOwn], T0.[U_Product], T0.[U_Olfactive1], T0.[U_Olfactive2], T0.[U_Olfactive3], T0.[U_Desc1], T0.[U_Desc2]

WHERE T0.[U_Brand] = $[OQUT.U_Brand] or T0.[U_BrandOwn] = $[OQUT.U_BrandOwn] or T0.[U_Product] = $[OQUT.U_Product] or T0.[U_Olfactive1] = $[OQUT.U_Olfactive1] or T0.[U_Olfactive2] = $[OQUT.U_Olfactive2] or T0.[U_Olfactive3] = $[OQUT.U_Olfactive3]

This returns all items where U_Brand is amber also all records where U_Olifactive1 = Fruity, what I want is only the records that match Amber and are Fruity. The or statement is cusing the problem, if I use the and statement then I must select something from each customised field.

Can anyone help me please
Sep 9 '08 #1
  • viewed: 1168
4 Replies
Expert 2GB
Do you want to include if all the other conditions are true?

Try using parenthesis to group your conditions...

-- CK
Sep 9 '08 #2

I want to include all records that match the two, three, or four entries that I make in the selection regardless of the values of any of the other fields. The combination of selected fields may well be different every time the product file is searched.

Thank you for Interest
Sep 10 '08 #3
Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. WHERE (T0.[U_Brand] = $[OQUT.U_Brand] or T0.[U_Olfactive1] = $[OQUT.U_Olfactive1]) and
  2. T0.[U_BrandOwn] = $[OQUT.U_BrandOwn] and T0.[U_Product] = $[OQUT.U_Product] and 
  3.  T0.[U_Olfactive2] = $[OQUT.U_Olfactive2] and T0.[U_Olfactive3] = $[OQUT.U_Olfactive3]
will return if U_Brand = OQUT.U_Brand or U_Olfactive1 = OQUT.U_Olfactive1...so if one of this condition is true, the whole condition is true...the rest, however, must be true in order to be the entire condition be true...

Good luck

-- CK
Sep 10 '08 #4
Thanks very much for your help, most appreciative.
Sep 11 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Lars Nielsen | last post: by
14 posts views Thread by Andre | last post: by
14 posts views Thread by Kukurydz | last post: by
4 posts views Thread by kenneth.osenbroch@telenor.com | last post: by
14 posts views Thread by guswebb | last post: by
reply views Thread by exclaim | last post: by
reply views Thread by Gosth in the shell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.