I'm writing some type of internet search engine for my web application and i've got a problem. I've 2 tables to begin is projects table:

PROJECTS TABLE

id                  int(11)         NO      PRI     NULL    auto_increment
employer_id         int(11)         NO      MUL     NULL     
project_title       varchar(100)    NO      MUL     NULL     
project_description text            NO              NULL     
project_budget      int(11)         NO              NULL     
project_allowedtime int(11)         NO              NULL     
project_deadline    datetime        NO              NULL     
total_bids          int(11)         NO              NULL     
average_bid         int(11)         NO              NULL     
created             datetime        NO      MUL     NULL     
active              tinyint(1)      NO      MUL     NULL     

PROJECTS_Abilities TABLE

project_id          int(11)         NO      MUL     NULL     
skill_id            int(11)         NO      MUL     NULL     

For instance: I would like request this question to database:

1-) Skills are 5 and 7.
2-) Order results by created
3-) project title contains "php" word.
4-) Returned rows should contain projects.* columuns.
5-) Projects should be distinct(i don't want same projects in return of query).

Please write sql query that ensure these conditions. Thanks.

It may sound like you are searching for an EXISTS query, which certifies that matching rows appear in a table, but without carrying out a JOIN.

SELECT *
FROM projects
WHERE EXISTS (SELECT 1 FROM projects_skills AS ps WHERE ps.project_id = projects.project_id AND ps.skill_id IN (5, 7))
    AND project_title LIKE '%php%'
ORDER BY created;
SELECT projects.*
FROM projects
WHERE EXISTS (
        SELECT *
        FROM projects_skills
        WHERE skill_id = 5 
            AND project_id = projects.project_id
    )
    AND EXISTS (
        SELECT *
        FROM projects_skills
        WHERE skill_id = 7
            AND project_id = projects.project_id
    )
    AND project_title LIKE '%php%'
ORDER BY created

or

SELECT projects.*
FROM projects
WHERE EXISTS (
        SELECT *
        FROM projects_skills
        WHERE skill_id IN (5, 7) 
            AND project_id = projects.project_id
    )
    AND project_title LIKE '%php%'
ORDER BY created

Based on what your intended outcome is.