473,480 Members | 3,062 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax for passing two values as criteria for one field

21 New Member
hi,

i have the foll query,

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT IngrID
  2. FROM IngredientDetails
  3. WHERE ProdID= (SELECT ProdID FROM ProductDetails
  4.                WHERE ProdName=('abc', 'xyz'))
it shows a syntz error near ProdName=('abc', 'xyz')) area...the same query works fine with just one prod name...i just want to know the rite syntax for mentioning both the prods in productname...for ProdName=('abc', 'xyz'))

kindly help
thanks!
May 25 '07 #1
8 1779
Rabbit
12,516 Recognized Expert Moderator MVP
You use In () instead of = ()
May 25 '07 #2
NeoPa
32,556 Recognized Expert Moderator MVP
You use In () instead of = ()
...In line #4.
May 26 '07 #3
zimitry
11 New Member
How does that SQL syntax work when you have not got a INNER JOIN ON for the second table?
May 26 '07 #4
NeoPa
32,556 Recognized Expert Moderator MVP
How does that SQL syntax work when you have not got a INNER JOIN ON for the second table?
I'm confused. There is no second table.
May 26 '07 #5
NeoPa
32,556 Recognized Expert Moderator MVP
I'm confused. There is no second table.
Ah, I understand.
The second table is within a sub-query. The sub-query returns the list of products in the specified list which are also in the [ProductDetails] table.

This also means, of course, that the query needs a bit more fixing than I'd realised.
May 26 '07 #6
NeoPa
32,556 Recognized Expert Moderator MVP
The fixed code should look like :
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT IngrID
  2. FROM IngredientDetails
  3. WHERE ProdID IN (SELECT ProdID FROM ProductDetails
  4.                  WHERE ProdName IN ('abc', 'xyz'))
Equally, a better way would be (Thanks for the spot Zimitry) :
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ID.IngrID
  2. FROM IngredientDetails AS ID
  3.      INNER JOIN ProductDetails AS PD
  4.   ON ID.ProdID=PD.ProdID
  5. WHERE PD.ProdName IN ('abc', 'xyz')
May 26 '07 #7
harini
21 New Member
thanks all! it worked! the mist was i used = ('abc' ,'xyz')...if its more than one name it shud be IN ('abc','xyz')...i changed the same n it works now...
May 29 '07 #8
NeoPa
32,556 Recognized Expert Moderator MVP
No problem Harini.
You should probably look at the alternative version though. It should be a better solution (and simpler - always good).
Good luck.
May 29 '07 #9

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

Similar topics

8
1774
by: Ike | last post by:
I am hoping someone can help me with the proper syntax for this. I have an attribute, called, say "name," such that: <set name="something">thename</set> However, the value for name, is...
4
2041
by: Aaron Walker | last post by:
Greetings, I'm attempting to write my first *real* template function that also deals with a map of strings to member function pointers that is making the syntax a little tricky to get right. ...
6
5251
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
2
2048
by: MX1 | last post by:
HELP! I have a query that gets a few values from a form. The problem I'm having is a date field in the query. When I put the value in the criteria, it works fine. When I put the same value as...
3
7536
by: MX1 | last post by:
I'm ready to pull the hair out of my head. I have a query with a couple of parameters that I want to get from combo boxes on a form. One parameter is a date with a dynamically calculated year and...
2
2521
by: Matthew | last post by:
Hey , I have built a query which takes values from unbounded fields on a form, and it all works except for one thing. I have a few fields in my query that are dates. I also have a start and...
33
7624
by: Birky | last post by:
Can you please help me understand how to build Criteria syntax within the Query Builder? If you have a field that is for a region (lets say for Midwest) and you have another field which breaks...
1
1448
by: Spanner77 | last post by:
Hi guys, I'm using Access 2002 and need to pass a parameter to a select query that will either return ALL records (including NULL values) OR exclude NULL values only, on a particular field. Put...
16
2430
by: Chuck | last post by:
Please help me correct the statements in sub "BoundData" The following sub is in a module. Everything runs with no error messages, however,data is not reaching the text box. Data is being...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7060
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
7106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7022
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
3013
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
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.