|
-
Mar 30th, 2000, 11:42 PM
#1
Thread Starter
Lively Member
Can anyone tell me how to search all fields in an SQL statement as opposed to just one? This is the code I want to change.
strQuery = "SELECT * FROM software WHERE Name LIKE '%" & SoftwareString & "%'"
I want to do a text search on all of the fields, not just the Name field. Thanks.
casox
-
Mar 30th, 2000, 11:55 PM
#2
Lively Member
You can try concatinating the Name and SoftwareString like this.
WHERE Name + SoftwareString Like "%"
I don't know if this is what you are looking for or not.
-
Mar 31st, 2000, 12:04 AM
#3
Thread Starter
Lively Member
I'll explain better. There are 10 fields, Name is one of them. Instead of searching the table for a matching Name, I want to search the table for anything the user enters. ex. if one enters a name, it will query all fields and display the record that contains that name irregardless of what field it's in. I guess you might say that all of the data in the entire table needs to become one big text string and we then query for one specific field within that string. This would also hold true if one entered a serial number or network name etc. The query would simply search all the fields for a match. I've done this with string manipulation but now I'm doing it within a dbgrid and need to search with an sql statement. Yes / No ?
Thanks,
Kim
[Edited by casox on 03-31-2000 at 12:08 PM]
-
Mar 31st, 2000, 12:45 AM
#4
Lively Member
I would say you were on the right track with your first select statement. I created a stored procedure that executed the select statement I wanted. I passed in the arguments that I wanted to search for. I would add % to the end on the data the user entered so the LIKE would work correctly.
To answer your original quetsion, I don't know of a way to search all the fields without using the AND between each field.
Sorry
-
Mar 31st, 2000, 01:06 AM
#5
Thread Starter
Lively Member
OK. It finally dawned on me what you were saying! Thanks, I'm sure the 'and' will work.
casox
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|