473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using IN operator with LIKE operator

I've got a number of 'Lots' of cattle - ie 40A, 372A, W123 etc. The
letter in the Lot number indicates where the animal is traceable or
not. The animal's Lot number, along with its individual details are
recorded in a table.

I have a second table tblLotTraceability, with the fields "LotLetter"
and "TraceabilityRequired". I have built a query (with an IN operator)
that searchs the tblLotTraceability table, returning all LotLetters
that are traceable as a parameter. The problem is that the "Lots" are
not just the letter, but a number as well. Usually I use a LIKE
operator (Like "*A*").... is there some way of doing a

-- Like "*In (SELECT LotLetter FROM tblLotTraceability WHERE
(((tblLotTraceability.TraceabilityRequired)=Yes)); )*" --

Cheers

Reg

Nov 13 '05 #1
4 8321

Regnab wrote:
I've got a number of 'Lots' of cattle - ie 40A, 372A, W123 etc. The
letter in the Lot number indicates where the animal is traceable or
not. The animal's Lot number, along with its individual details are
recorded in a table.

I have a second table tblLotTraceability, with the fields "LotLetter"
and "TraceabilityRequired". I have built a query (with an IN operator)
that searchs the tblLotTraceability table, returning all LotLetters
that are traceable as a parameter. The problem is that the "Lots" are
not just the letter, but a number as well. Usually I use a LIKE
operator (Like "*A*").... is there some way of doing a

-- Like "*In (SELECT LotLetter FROM tblLotTraceability WHERE
(((tblLotTraceability.TraceabilityRequired)=Yes)); )*" --


A little DDL would be helpful here. I suspect that what you want is
possible.

Edward

Nov 13 '05 #2
Regnab wrote:
I've got a number of 'Lots' of cattle - ie 40A, 372A, W123 etc. The
letter in the Lot number indicates where the animal is traceable or
not. The animal's Lot number, along with its individual details are
recorded in a table.

I have a second table tblLotTraceability, with the fields "LotLetter"
and "TraceabilityRequired". I have built a query (with an IN operator)
that searchs the tblLotTraceability table, returning all LotLetters
that are traceable as a parameter. The problem is that the "Lots" are
not just the letter, but a number as well. Usually I use a LIKE
operator (Like "*A*").... is there some way of doing a

-- Like "*In (SELECT LotLetter FROM tblLotTraceability WHERE
(((tblLotTraceability.TraceabilityRequired)=Yes)); )*" --

Cheers

Reg

Why not create a query and drop in your two tables?

Set a relationship on LotLetter between the two. Drag LotLetter from
your Lot table into a column. Set the criteria to Like "*A*

Drag TraceabilityRequired into another column from the
tblLotTraceability table. Set the criteria to True.

Keep it simple.
Nov 13 '05 #3
Sorry Salad - I may not have explained the table structure properly

2 tables - tblLotTraceability, tblInductions

Field: tblLotTraceability - LotLetter, Grade, TraceabilityRequired
tblInductions - Lot, VisualID, Weight etc....

The link is that the "tblInductions.Lot" has the
"tblLotTraceability.LotLetter" somewhere within it - hence the need to
use like. There are about 10 different letters, and could have multiple
Lots associated with them - I might import 2 A lots (21A, 45A), a
couple of W lots (W140, W133) and so on. I'm trying to get a link
between them to check traceability... if this is the way you understood
it, then maybe I've misunderstood your solution.

Cheers

Reg

Nov 13 '05 #4
Ended up just doing it in the code after the files are imported.

Private Sub UpdateLetterLotMatchup()
Dim arrLetter As Variant
Dim N As Integer

arrLetter = Array("A", "B", "C", "D", "E", "F", "G", "H", "X", "W",
"S", "T", "R", "Y")
N = 0

DoCmd.SetWarnings False

DoCmd.RunSQL "DELETE * FROM tblLetterLotNum;"

For Each I In arrLetter
DoCmd.RunSQL "INSERT INTO tblLetterLotNum (LotNumber, Letter) "
& _
"SELECT tblInductions.LotNumber, '" & arrLetter(N)
& "' " & _
"FROM tblInductions " & _
"GROUP BY tblInductions.LotNumber " & _
"HAVING (((tblInductions.LotNumber) Like '*" &
arrLetter(N) & "*'));"
N = N + 1

Next I

DoCmd.SetWarnings True

End Sub

Best way I could think of doing it - constructive critisism always
welcome....still learning ;)

Cheers

Reg

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: sandSpiderX | last post by:
Hi, How do i use this definition of overloaded operator, T& operator*(T*); like struct X {}; X ox; X* px=&ox;
10
by: Steve Jorgensen | last post by:
Microsoft acknowledges a bug with this, but the bug is worse than they say. It turns out that if you use the Like operator without a wildcard on a snapshot type recordset, all sorts of wierd,...
3
by: Neil Zanella | last post by:
Hello, I would like to ask the following question concerning the C# as operator. I would like to know whether the difference between using a C-style cast such as double x = 0; float y =...
2
by: Ed Brown | last post by:
I'm working on a VB.Net application that needs to do quite a bit of string pattern matching, and am having problems using the "LIKE" operator to match the same string twice in the pattern. For...
1
by: Number 5 | last post by:
Hi I am encountering some problems with SQL. I am trying to create a search query where a person enters some keywords into a textbox called "Subjects2" on a form called "Doc_search" and is...
2
by: neeraj | last post by:
Hi, all Could anny one give me help how can I use like operator with these data types "integer , datetime or boolean" in DataView.RowFilter Actually when I try to get the data from dataview...
11
by: dascandy | last post by:
Hello, I was wondering, why is overloading operator. (period) forbidden? It would make a few odd applications possible (dynamic inheritance and transparent remote method invocation spring to my...
2
by: Deepa Jeevagan | last post by:
Hi, The application I am currently working on is developed in Oracle 8i. I have a table which has a nullable numeric column say CustNo. This column has an index defined on it and oracle uses...
0
by: Gary | last post by:
In a newly converted database (ACCDB from A97 MDB) I'm seeing the following behavior. In the query design grid (of existing or of newly created queries), after entering a criteria statement...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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
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,...

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.