0

hi all,
i had 4 text boxes.
1.Emp_id
2.Emp_Name
3.Mobile No
4.Blood group
and a search Button.
so when i fill any textbox or all the textboxes then it should display the required data.
For example:
If i want some person details. i know only his name.Then if i enter in the Emp_Name textbox then it should display Emp_id,Emp_Name,GEnder,MobileNo,Emailid,Bloodgroup.

select Employee.Emp_Id,First_Name,Last_Name,Gender,Mobile_No,Email_id,Blood_Group from Employee
where Emp_Id like ('%' + '$empid' + '%') and First_Name like ('%' + '$empname' + '%') and Mobile_No like ('%' + '$mobileno' + '%') and Blood_Group like ('%' + '$bloodgroup' + '%')

i tried for this but i am not getting...
so can anyone help me.
Thank u...

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by smantscheff
0

Use OR instead of AND:

select Employee.Emp_Id,First_Name,Last_Name,Gender,Mobile_No,Email_id,Blood_Group from Employee
where Emp_Id like ('%' + '$empid' + '%') OR First_Name like ('%' + '$empname' + '%') OR Mobile_No like ('%' + '$mobileno' + '%') OR Blood_Group like ('%' + '$bloodgroup' + '%')
0

If your code is supposed to be PHP, it should read

...where Emp_Id like ('%$empid%') and...

assuming it is quoted with double quotes.
If it is supposed to by JavaScript, drop the '$' before the variable names.
If it is supposed to be plain MySQL, it might rather read:

...where Emp_Id like concat('%', @empid, '%') and...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.