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...

Recommended Answers

All 2 Replies

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' + '%')

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...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.