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

<?php

    $partialStates = $_POST['partialState'];

    $states=mysql_query("


    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.

Your query appears correct. Did you try it in phpMyAdmin or something similar?

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.