-
Nov 4th, 2018, 01:34 PM
#1
Thread Starter
Addicted Member
How to using like operator and wildcard with Mysql ?
Hello everyone,
good day,
i use this code to search in access database and work good
Code:
RS.Open "select * from Table1 where Name and Code like '" & Trim(Text1.Text) & "%'", DB, adOpenStatic, adLockOptimistic
Do Until RS.EOF
Grid1.AddItem RS!Paccode & vbTab & RS!Name
RS.MoveNext
Loop
but if i use this code with mysql database don't show the data, i can't search more than one fields
so when code only like this work fine with Mysql database
Code:
RS.Open "select * from Table1 where Name like '" & Trim(Text1.Text) & "%'", DB, adOpenStatic, adLockOptimistic
how i using like operator and wildcard together ?
waiting for help
Best Regards
-
Nov 5th, 2018, 08:01 AM
#2
Re: How to using like operator and wildcard with Mysql ?
SQL isn't like English... it doesn't understand what you mean by "where Name and Code Like...." so you have to be specific ....
"where Name like 'something%' and Code like 'Something%' "
Yes... that means if you want to more than two fields, you have to do that for each and every field...
-tg
-
Nov 5th, 2018, 10:34 AM
#3
Thread Starter
Addicted Member
Re: How to using like operator and wildcard with Mysql ?
Thank you for your replay
i try to edit the code to be specific but not working and show error
i need to search in mysql when i typing in Textbox like make filter data
waiting for help
-
Nov 5th, 2018, 11:24 AM
#4
Re: How to using like operator and wildcard with Mysql ?
well, unfortunately my crystal ball is in the shop being fixed, and I'm not sitting in your lap, so I don't see what you're seeing, so I have no idea what error you're getting.
-tg
-
Nov 6th, 2018, 12:47 PM
#5
Thread Starter
Addicted Member
Re: How to using like operator and wildcard with Mysql ?
i just need help to edit this code to work with mysql and filter data when i typing in textbox
i try to edit code but not working so could you please edit this code to work fine
waiting for help
Best Regards
-
Nov 7th, 2018, 04:15 PM
#6
Re: How to using like operator and wildcard with Mysql ?
He already showed you what you needed to do, but you still have not shown the code you supposedly modified using his recommendation. I am surprised the code you showed at the top of the first post worked in Access. Correct SQL syntax would be like TG said
Code:
SELECT * FROM Table1 WHERE Name LIKE 'somepartialstring%' AND Code LIKE 'anotherpartialstring%';
This works perfectly fine in MySQL 5.6.35.
-
Nov 8th, 2018, 04:43 PM
#7
Re: How to using like operator and wildcard with Mysql ?
Originally Posted by topshot
I am surprised the code you showed at the top of the first post worked in Access.
yes,it works in MSaccess, provided you tell MSaccess to use SQL-92
(SQL-92 is an option since MSaccess 2003, if i remember correctly)
but i am almost 100% sure it will not return what vbgedo thinks it will return
vbgedo, try leaving the Name field blank in a few records
do not put off till tomorrow what you can put off forever
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
|