0

i have this search function to search for Firstname Middlename individually with their own CheckBox, this thing came to my mind if i want to search for Firstname and Middlename together in one Textbox with space of course and tried to use SELECT statement with CONCAT, but it didn't work.

it looks like this one:

If CheckBox1.Checked And CheckBox2.Checked Then
            SQL = "SELECT * from student where CONCAT(fname,"" "", mname) like '%" & TextBox1.Text & "%'"
End if
0

1 Answer 1

1

Try this:

If CheckBox1.Checked And CheckBox2.Checked Then
  SQL = "SELECT * from student where CONCAT(fname,' ', mname) like '%" & TextBox1.Text & "%'"
End if

EDIT

SELECT * FROM student WHERE MATCH (fname, mname) AGAINST ('+" & TextBox1.Text & "* +" & TextBox1.Text & "*' IN BOOLEAN MODE)

Might be this will give you the desired result

Sign up to request clarification or add additional context in comments.

2 Comments

still doesn't work, if i press space after the Firstname, it shows nothing.
@SkyScraper- I think then you must have a look on Full-Text Search Functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.