Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 24th, 2006, 1:17 PM   #1
starfishdestroyer
Newbie
 
Join Date: Jan 2006
Posts: 1
Rep Power: 0 starfishdestroyer is on a distinguished road
Question SQL script. i need help

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!
starfishdestroyer is offline   Reply With Quote
Old Jan 24th, 2006, 1:36 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Jan 25th, 2006, 10:02 AM   #3
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Describe the table - ie., give us the names of the columns.
The operator you are probably looking for is LIKE
jim mcnamara is offline   Reply With Quote
Old Jan 25th, 2006, 10:50 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,464
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Jan 25th, 2006, 11:56 AM   #5
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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!
Pizentios is offline   Reply With Quote
Old Dec 1st, 2006, 5:18 PM   #6
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4 mackenga is on a distinguished road
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:
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?
Basically, the answer is Yes. That's the bread and butter of SQL.

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?"
mackenga is offline   Reply With Quote
Old Dec 2nd, 2006, 4:55 AM   #7
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 816
Rep Power: 4 The Dark is on a distinguished road
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.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC