hi,
i have the foll query, - SELECT DISTINCT IngrID
-
FROM IngredientDetails
-
WHERE ProdID= (SELECT ProdID FROM ProductDetails
-
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!
8 1779 Rabbit 12,516
Recognized Expert Moderator MVP
You use In () instead of = ()
NeoPa 32,556
Recognized Expert Moderator MVP
You use In () instead of = ()
...In line #4.
How does that SQL syntax work when you have not got a INNER JOIN ON for the second table?
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.
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.
NeoPa 32,556
Recognized Expert Moderator MVP
The fixed code should look like : - SELECT DISTINCT IngrID
-
FROM IngredientDetails
-
WHERE ProdID IN (SELECT ProdID FROM ProductDetails
-
WHERE ProdName IN ('abc', 'xyz'))
Equally, a better way would be (Thanks for the spot Zimitry) : - SELECT DISTINCT ID.IngrID
-
FROM IngredientDetails AS ID
-
INNER JOIN ProductDetails AS PD
-
ON ID.ProdID=PD.ProdID
-
WHERE PD.ProdName IN ('abc', 'xyz')
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...
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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.
...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |