473,546 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
+ 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...f or ProdName=('abc' , 'xyz'))

kindly help
thanks!
May 25 '07 #1
8 1783
Rabbit
12,516 Recognized Expert Moderator MVP
You use In () instead of = ()
May 25 '07 #2
NeoPa
32,564 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,564 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,564 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,564 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,564 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
1777
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 something that is unknown, something within tags itself. So, for example, the tag <star index="1"/> might be "something." How then can I express, or...
4
2048
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. The function in question: 36: template <typename Container, 37: typename OutputIterator,
6
5258
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 all querying is done locally. One of the reports we run allows the user to list all invoices within a period. They are also allowed to select a...
2
2056
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 an item in a combo box of the form and try to pass the value, I get "This expression is typed incorrectly or too complicated to be evaluated". ...
3
7541
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 the other is criteria for a Yes or No field. I'll focus on the Yes/No field for simplicity. If I run the query with the criteria hard coded as...
2
2527
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 end date and time on my form. So, a user will specify the start and end date, and also, the user has the option of checking which of the time fields...
33
7629
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 it down into a smaller geographical region like City (lets say Denver) how can I build the Criteria within the Query Builder to key off a previous...
1
1452
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 another way, I need to give the user the ability to set a particular field as follows: Criteria: 'Is Not Null' (return all records where the...
16
2437
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 appended to WorkingTable but not filtered by value in text box. If I input data into the text box, it gets deleted by the sub routine, indicating that...
0
7694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7792
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
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 we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.