Gerald Maher wrote:
I need to select 2 tables . The field 'p_description' is not always
aviable but i still need to print it to the screen
I think you are mixing up terminology a little bit. In your example,
p_description is a table, not a field. pTaskLink and TaskID are fields.
When you say "is not always available" what do you mean? Do you mean
that there not every row in the task table has a corresponding row in
the p_description table?
SELECT *
FROM task,p_description
WHERE ComponentIDLink = 34 OR task.TaskID = p_description.pTaskLink
GROUP BY TaskID ORDER BY TaskName
This is called an inner join. It returns a row only when there is an
equal value in both the task table and the p_description table.
If i use AND it works, but there are colums missing
I think you mean that there are rows missing, not columns. If so, you
need to use an outer join. An outer join is where you get every row in
one table, even if there aren't any matching rows in the other table.
In those cases, the values for the second table are returned as NULL.
SELECT t.*, p.*
FROM task t LEFT OUTER JOIN p_description p ON t.TaskID = p.pTaskLink
WHERE t.ComponentIDLink = 34
GROUP BY t.TaskID
ORDER BY t.TaskName
I'm guessing at which field is in which table, because I can't be
certain from your example query.
I think you need to study some basics about databases and queries, so
you can understand inner and outer joins, and also so you can use
correct terminology when you ask questions. It'll make the questions
clearer and people will be able to answer more accurately.
Regards,
Bill K.