944,149 Members | Top Members by Rank

Ad:
Mar 14th, 2005
0

SQL statement to query user input??

Expand Post »
Hi GUys

Just wondering if any one can help me out. Basically i wnat to create an SQL query which will take the input of the user and query that specific variable:

e.g the user enetrs in a field, the value entered is assigned to variable "srch", then in my SQL query i want whatever has been entered to be pattern matched to the data stored in the database, would the query possibale be something like this:

SELECT functionme FROM MsgeTble WHERE alternme LIKE "*$srch*"

Im pretty novice in databases

Please any suggestions would be grateful! Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nelly_1005 is offline Offline
11 posts
since Feb 2005
Jun 27th, 2006
0

Re: SQL statement to query user input??

Hey ppl,

I also have the same problem, but I usually dont have as much time to log on here. If anybody does have the answer, plz email me at husseinmohamedali@gmail.com. Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
HMC1991 is offline Offline
2 posts
since Jun 2006
Mar 31st, 2007
0

Re: SQL statement to query user input??

Click to Expand / Collapse  Quote originally posted by nelly_1005 ...
Hi GUys

Just wondering if any one can help me out. Basically i wnat to create an SQL query which will take the input of the user and query that specific variable:

e.g the user enetrs in a field, the value entered is assigned to variable "srch", then in my SQL query i want whatever has been entered to be pattern matched to the data stored in the database, would the query possibale be something like this:

SELECT functionme FROM MsgeTble WHERE alternme LIKE "*$srch*"

Im pretty novice in databases

Please any suggestions would be grateful! Thanks



HI...

There is 2 ways.
i) u can write in the Qurey
just u have to enter in the last field like this : [Enter the Name]
and in Criteria: u have the write the filed name
like:
[Enter the Name]
Field Name

ii) u can write in the code
set db = currentdb
set rec = db.oprecordset("Select * from MsgeTble WHERE ename = " & text1.value & "")

if not(rec.bof and rec.eof) then
rec.movefirst
while not rec.eof
text1.value = rec.field("aaa")
rec.movenext
wend
end if


*********************

kindly try this if not work than reply me...

Bye...
Rupesh
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rupeshba is offline Offline
4 posts
since Mar 2007
Feb 10th, 2010
0
Re: SQL statement to query user input??
You could try the following syntax:

SELECT *
FROM TABLE
WHERE FIELDNAME=?;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EZHIL_VINUJIN is offline Offline
2 posts
since Feb 2010
Feb 10th, 2010
0
Re: SQL statement to query user input??
You could try the following syntax:

SELECT *
FROM TABLE
WHERE FIELD=?;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EZHIL_VINUJIN is offline Offline
2 posts
since Feb 2010
Feb 24th, 2010
0

quey statement

select statement
select * from table_name where column_name='&column_name';

for insert
insert into table_name values ('&column_name1','&column_name2');
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nandini bk is offline Offline
1 posts
since Feb 2010
Mar 1st, 2010
0
Re: SQL statement to query user input??
Here is a piece of code that does something similar to what you want I thnk.


Dim WhereClause As String
Dim AndStr As String

AndStr = ""
If Me.SearchName <> "" Then
    WhereClause = "(FirstName like '*" & Me.SearchName & "*' OR Surname like '*" & Me.SearchName & "*')"
    AndStr = " AND "
End If
If Me.SearchSuburb <> "" Then
    WhereClause = WhereClause & AndStr & "Suburb like '*" & Me.SearchSuburb & "*'"
    AndStr = " AND "
End If
If Me.SearchCompany <> "" Then
    WhereClause = WhereClause & AndStr & "CompanyName like '*" & Me.SearchCompany & "*'"
    AndStr = " AND "
End If

If Me.searchRep <> "" Then
    WhereClause = WhereClause & AndStr & "Rep='" & Me.searchRep & "'"
        AndStr = " AND "
End If

If Me.SearchStatus <> "" Then
    WhereClause = WhereClause & AndStr & "Status='" & Me.SearchStatus & "'"
    AndStr = " AND "
End If
PerformSearch:
Me.Filter = WhereClause
Me.FilterOn = True
Last edited by ChrisPadgham; Mar 1st, 2010 at 12:04 am.
Reputation Points: 88
Solved Threads: 63
Posting Whiz
ChrisPadgham is offline Offline
325 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS Access and FileMaker Pro Forum Timeline: query with combo box input
Next Thread in MS Access and FileMaker Pro Forum Timeline: I need help in updating an ms access database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC