473,699 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you do a query to find a 1-digit number in a comma separated list?

1 New Member
I am trying to figure out how to do a query in Access 2000 that will find all records that contain the number 1. The problem is that the particular field I am searching has lists of numbers in it separated by commas. For example, the field may contain the numbers 1,71,38,81. (The field is formatted as a text field) I want to pull up all the records that contain the number 1, but if I search for 1, I also get records that contain 71 or 61 or some other number that contains a 1 as one of its digits.

I WOULD want it to return the above example, because it contains a 1 by itself, but I would NOT want it to return the following: 61,83,85 because it does not contain the number 1 by itself.

Is there some way to specify that I am searching for a single character? That would mean YES to "1" but NO to "61"?
Aug 28 '07 #1
3 1894
JKing
1,206 Recognized Expert Top Contributor
Have you tried using the like operator and specifying the commas.

Example: WHERE field LIKE ',1,'
Aug 28 '07 #2
mlcampeau
296 Recognized Expert Contributor
Have you tried using the like operator and specifying the commas.

Example: WHERE field LIKE ',1,'
I had the same thought as JKing, but you will want to take into consideration that 1 could be in the first place in the list or last place as well. JKing's example would take into consideration that 1 is in the middle of the list. To take care of the other situations try this:

WHERE field LIKE '1,*' OR field LIKE '*,1,*' OR field LIKE '*,1'
Aug 28 '07 #3
missinglinq
3,532 Recognized Expert Specialist
I think the more important question here is exactly what kind of data are you storing in this field? It sounds like you're storing multiple values in a single field which is very, very poor practise, and leads to all kinds of problems, as I believe you've already discovered. Perhaps we could offer you an alternative approach if we knew a little bit more about your situation.

Linq ;0)>
Aug 28 '07 #4

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

Similar topics

9
3130
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
3
7874
by: Jonathan | last post by:
Hi all! For a match schedule I would like to find all possible combinations of teams playing home and away (without teams playing to themselves of course). I now the simple version works something like this: For a (very) simple table containing three rows like this: row 1: A
1
3085
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from a specific state. In order to generate that, I create a form, I put a combobox with the states and a Command Button which opens a report. The report is based on a query, qryCustomersByState which has a parameter (State) taken from the Form.
2
1948
by: planetthoughtful | last post by:
Hi All, I'd like to place a subreport onto a report that draws its records from a UNION query. When I design the query and view the records all looks fine. However, when I put the query as the subreport's data source and open it, Access complains that Jet can't find the table, and then when I open up the query itself to look at the SQL, it appears all mangled.
30
2330
by: Paul H | last post by:
I seem to end up with loads of append and update queries just because it's quick and easy to build queries or make a new ones based on an existing query. But I end up with loads of queries with long names like: qryfrmCustomers_Diary_DeleteEntriesBeforeADate qryfrmMaintenance_CloneOrder_Step1_CreateOrderIDAndDescription Am I being lazy? Should I code most of my action queries to tidy up the clutter in the database window?
5
7364
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the same command inside of mysql_real_query and I keep on getting this error back. "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
1
1681
by: hardik | last post by:
hi friends i need help in this sql query i have table like, id fid __ _____ autonumber text and i am storing values like
1
2021
by: JC | last post by:
Hello, I am trying to change a select, find duplicates, query into a delete query. I want to get rid of the records in the main table "tblHurnsHistory." I changed the Find Duplicates query to a Delete query. I then received an input box looking for criteria that states," Enter parameter value qryHurnsHistory.Grads_creditsEarned
9
3055
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
7
3475
by: nhkam | last post by:
I am using MS Access 2007 I have a transaction table which holds all records with posting date on each of them. I used a make table query to find out the max date hold in the transaction table and use the dateAdd function to find the date with 1 month, 5 months and 6 months ago and export it into a table name TRSMPD that only have one record. I then use the TRSMPD table to query the transaction table to find the records that has dates greater...
0
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5874
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
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
3
2009
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.