Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a quick lesson in querying my database.

Status
Not open for further replies.

kg9ie

Technical User
Jun 3, 2000
18
0
0
US
I'm working on my first database intensive program, and I don't have any good references on SQL.

I couldn't even get a simple SELECT statement to work. What I need is a sample statement. Here's what I tried:
"SELECT * from myTableName WHERE " & myTableField & "=" & myData

myData is a string. The database is Access, and I get a syntax error on SQL statement.

Can someone please help?
Any good references on the Net?


Thanks,
Todd
 
myData is a string
Strings have quotes round them. "=" & myData should be more like
"= '" & myData & "'"

If mydata contains a ', then you need to replace it with '' first.

Try that. If you still have problems post a chunk of code. Peter Meachem
peter @ accuflight.com

 
Check spaces round equals signs as well Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Spaces round = signs don't matter. Extra spaces round string do

This is ok

"SELECT * from myTableName WHERE " & myTableField & " = '" & myData & "'"


This isn't

"SELECT * from myTableName WHERE " & myTableField & "=' " & myData & " ' "
Peter Meachem
peter @ accuflight.com

 
Thanks Peter.

You were right.


Todd
 
For quick easy to understand lessons try SQL in 24 Hours by SAMS, I always find that these 24Hr books give you a good foot hold when you're very new to something.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top