![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2006
Posts: 1
Rep Power: 0
![]() |
hi,
im kind of a newbie when it comes to SQL programming. i dont even know if im in the correct part of the website or what. i just have a question that is complicated for me. "is it possible to create an sql script that will search for a particular string in a database table (in ms access) and wil return the whole row of the string that is being searched?" if this is possible, please email me. many thanks! ![]() |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
How is an email going to help other members that may need the same answer? You realize that a "row" normally comprises multiple fields, right? You should be clear about whether or not the target string will always appear in the same field, or whether it might occur in any of the fields. For a decent answer, explain your setup clearly, as well as your goal. In Access, such searches may be done by coded modules or ememplar queries as well as by SQL queries.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
Describe the table - ie., give us the names of the columns.
The operator you are probably looking for is LIKE |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Need more info, so my answer will be relatively broad:
SELECT * FROM yourtable WHERE yourvalue IN ('list','of','values'); or SELECT * FROM yourtable WHERE yourvalue LIKE '%somesubstring%';
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
IR is correct, i would have done it the second way that he listed.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#6 | |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4
![]() |
Having said that, a SELECT with only a LIKE in the WHERE clause and with % at the start and end of the operand to LIKE is going to be slow as hell. To refer back to the original question:
Quote:
Your query will start: SELECT * which means 'give me the values of all the columns for each row of the result'. Next up you want: FROM tableName (but replace tableName with the name of the table). Now you want to say something about which rows. Say you wanted to search a table called Customers for a row where Surname was Smythe: SELECT * FROM Customers WHERE Surname = 'Smythe' Well I hope this is helpful.
__________________
"I'm not a genius. Why do I have to suffer?" |
|
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
mackenga, whats with dragging up all these old threads? This one is 10 and a bit months old, the original poster has had time to meet someone and be looking after a newborn baby by now.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|