473,499 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSSQL Query

3 New Member
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]

FROM OITM T0
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
4 1369
ck9663
2,878 Recognized Expert Specialist
Do you want to include if all the other conditions are true?

Try using parenthesis to group your conditions...

-- CK
Sep 9 '08 #2
flet
3 New Member
Hi

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
ck9663
2,878 Recognized Expert Specialist
This:
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
flet
3 New Member
Thanks very much for your help, most appreciative.
Sep 11 '08 #5

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

Similar topics

3
20906
by: Lars Nielsen | last post by:
I'm trying to execute a long query with mssql_query(), but it fails after 30 seconds. I've tried to use ini_set in my script : ini_set("mssql.timeout", "120"); Both just before the query and...
14
36954
by: Andre | last post by:
Hello Can anyone help me translate this from access so that it can work in mssql (i need to get next value, but cannot use identity as if row is deleted, another must get new next column number...
14
2440
by: Kukurydz | last post by:
I've got such problem: My database is stored on MSSQL Server. I have to write reports for it in MSAccess. I've got a problem with creating a query which will select records from MSSQL table with...
4
5968
by: kenneth.osenbroch | last post by:
Hi, I have a MSSQL Server communicating with an Oracle database through a MSSQL linked server using a MS ODBC connection. If I query the Oracle database through the Oracle ODBC 32Bit Test, the...
0
1295
by: intergroove | last post by:
Help. This has been bugging me for a couple of days now: I am writing a script to regularly transfer data from a MYSQL db to a MSSQL. Being new to MSSQL I'm a bit freaked out about the...
14
2900
by: guswebb | last post by:
Hi. I'm a newbie to PHP and am having a few problems as follows... I have installed PHP successfully on server 1 which is running IIS 6 (W2k3) and hosting multiple sites, some of which connect to...
1
2651
by: mkepick | last post by:
migrated databases from sybase to mssql, migration exported sybase written queries written with the application build in query tool and imported to mssql databases. all db and tables migrated...
0
1480
by: exclaim | last post by:
Apologies if this is not the right forum. I have an application written originally to work with MySQL which now has to be extended to work with MSSQL also. I have modified all my database calls...
0
1763
by: Gosth in the shell | last post by:
Hi there, i need some help I got a software to backend is MSSQL 2005, but a provider software requires an UPDATE on his table with MySQL 5.0.56a backend, so i made the next: download and...
2
2614
by: akronymn | last post by:
I have an mssql database that I need to migrate to mysql. For some reason though any queries to any columns of type datetime are returned in French in the following format: 7/avr/2004 14:00 ...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.