|
-
Oct 6th, 2011, 07:26 AM
#1
Thread Starter
Addicted Member
Putting a parameter in search query
Hello, I have a query in my sql builder like this
Code:
SELECT *
FROM canvasstable
WHERE (Material_Description LIKE '%a%')
That code is 100% working. My problem is I cant change it to something like this
Code:
SELECT *
FROM canvasstable
WHERE (Material_Description LIKE '%' + @parameters +'%')
I also tried something like this
Code:
WHERE (Material_Description LIKE CONCAT(@param, '%') AND = CONCAT('%', @param)
Please Help I really need it as much as possible. This is for our system.
-
Oct 6th, 2011, 11:03 AM
#2
Re: Putting a parameter in search query
1) Is it MySQL,
2) Is it is in STORED PROCEDURE
3) are you trying to pass the SQL via front end
the simple way is pass the parameter value with %
some thing like this
Code:
SELECT * FROM TABLE WHERE TABLE.CRITERIA LIKE @PARAM;
IF in side the UD_SP then
@PARAM = CONCAT('%',YOUR_PARAMETER,'%')
IF you are executing the SQL from front end ( via ADO ) then also the thing is same
-
Oct 6th, 2011, 11:36 AM
#3
Re: Putting a parameter in search query
try this:
Code:
(Material_Description LIKE ('%' + @parameters +'%'))
-tg
-
Oct 6th, 2011, 12:20 PM
#4
Thread Starter
Addicted Member
Re: Putting a parameter in search query
Thanks tg
Code:
1) Is it MySQL,
2) Is it is in STORED PROCEDURE
3) are you trying to pass the SQL via front end
IF you are executing the SQL from front end ( via ADO ) then also the thing is same
1. Yes
2. No
3. I think no, not sure.
I'm using creating it in this

then calling it in the event of the textbox textchange.
Thanks TG I really need it as much as possible because the defense of our system will be on monday, now it is friday 1:00am in the philippines.
-
Oct 6th, 2011, 12:26 PM
#5
Re: Putting a parameter in search query
I can tell from the screen shot there that you didn't followclose enough... the parenthesis should be AFTER the like... not before...
-tg
-
Oct 6th, 2011, 12:32 PM
#6
Thread Starter
Addicted Member
Re: Putting a parameter in search query
Oops! Sorry for that. I just intended to show you the way of how I use the query to answer your question number 3 "3) are you trying to pass the SQL via front end"
The screenshot you see is the query that I'm experimenting. 
By the way
Code:
(Material_Description LIKE ('%' + @parameters +'%'))
doesnt work
Everytime I enter in the query builder this code
Code:
(Material_Description LIKE ('%' + @parameters +'%'))
Then by pressing execute query the query automatically becomes like this, and error are popping.
Code:
(Material_Description LIKE '%' + @parameters + '%')
Last edited by cary1234; Oct 6th, 2011 at 12:33 PM.
Reason: Forgot something
-
Oct 6th, 2011, 12:36 PM
#7
Thread Starter
Addicted Member
Re: Putting a parameter in search query
Oops, sorry make_me_rain i though you are techgnome. Im just in a hurry.
this answer is for you.
Code:
1) Is it MySQL,
2) Is it is in STORED PROCEDURE
3) are you trying to pass the SQL via front end
IF you are executing the SQL from front end ( via ADO ) then also the thing is same
1. Yes
2. No
3. I think no, not sure.
I'm creating it in this

then calling it in the event of the textbox textchange.
-
Oct 6th, 2011, 12:44 PM
#8
Re: Putting a parameter in search query
This is a query builder IDE!!, just as QBE in access,
lets say like this
vb Code:
Dim SQL As String = _ "SELECT Material_Description FROM yourTable WHERE yourTable.Material_Description " _ & " LIKE @PARAM" Dim Input_Param As String = "% " & "Some Parameter" & " % "
do not go for the QBE
-
Oct 6th, 2011, 12:49 PM
#9
Thread Starter
Addicted Member
Re: Putting a parameter in search query
Code:
Dim SQL As String = _
"SELECT Material_Description FROM yourTable WHERE yourTable.Material_Description " _
& " LIKE @PARAM)"
Dim Input_Param As String = "% " & "Some Parameter" & " % "
I will type those codes inside the event in vb.net??? I cant understand how to use those code. haha! Thanks make me rain.
-
Oct 6th, 2011, 12:53 PM
#10
Re: Putting a parameter in search query
i didn't fallow you CARY, what you said & what you are trying for,
Ok any how good night, see u later
-
Oct 6th, 2011, 12:55 PM
#11
Thread Starter
Addicted Member
Re: Putting a parameter in search query
Hmm.. Strange.. Anyways thanks make me rain. Good night! Catch u later!
-
Oct 6th, 2011, 05:57 PM
#12
Thread Starter
Addicted Member
Re: Putting a parameter in search query
Anybody here? Help urgently needed. Please.
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
|