SoftwareDev
SoftwareDev

Reputation: 356

The SQL LIKE clause

to search employee based on job post and experience we can simply do like this if the table contains field like job post and experience

$sql="select FirstName, title, experience from applied_employee where title like '$_POST[jobtitle]' and experience like '$_POST[experiance]'";

but what query to write when table applied_employee contains only id of the jobtitle and id of the employee. i m new to the sql query and programming.thanks in advance.

Upvotes: 0

Views: 87

Answers (2)

SoftwareDev
SoftwareDev

Reputation: 356

following query works for me

    SELECT e.FirstName, j.title   FROM applied_employee ae, employees e, jobs j
WHERE ae.employeeID = e.emp_id
AND j.jobid = ae.a_jobid
AND e.FirstName LIKE  '$_POST[FirstName]'
AND j.title   LIKE  '$_POST[title]';

Upvotes: 1

Rainer Berger
Rainer Berger

Reputation: 211

If the table applied_employee does not contain the needed information, you will need to join that table with the other table(s) that contain the information. For example, suppose the other information is in a table called employee, then the the tables are joined by an employeeID field, the SQL statement might look something like

select e.FirstName, e.title, e.experience 
from applied_employee ae, employee e 
where ae.employeeID = e.employeeID
and e.title like '$_POST[jobtitle]' 
and e.experience like '$_POST[experiance]

Upvotes: 0

Related Questions