Hello all, I'm hoping you can help me with my first search engine/join query. I have 3 tables with differing numbers of coulumns - clients, projects and tasks.

Table "clients" with the columns "cid", "client" and "date"

Table "projects" with the columns "pid", "cid", "projects" and "date"

Table "tasks" with the columns "tid", "pid", "cid", "tasks", "company", "owner",

"priority", "target" and "status".

The purpose of the search is to find any given task quickly. I'd like the user to
input a client name and see all the information from the 3 tables that pertain to
that client. Similarly, the user should be able to input a project type and
recieve a list of all tasks in that current project type and all associated
information to that project from the other tables as well.

I've been experimenting with JOINs and UNIONs and not getting too far. Here is my


    $partialStates = $_POST['partialState'];


    SELECT tasks.tid, tasks.task, tasks.company, tasks.owner, tasks.priority, tasks.target, tasks.status
    FROM tasks
    LEFT JOIN projects ON projects.pid = tasks.pid
    LEFT JOIN clients ON clients.cid = projects.cid
    WHERE task LIKE '$partialState%'

                        ")or die ('Error: '.mysql_error ());;
    while($state = mysql_fetch_array($states)) {
        echo "<div>".$state['task']."</div>";


If any of you could send me in the right direction, it would be greatly appreciated.

Edited by strongpot

6 Years
Discussion Span
Last Post by pritaeas
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.