Gossamer Forum
Home : General : Databases and SQL :

Help with query

Quote Reply
Help with query
I have two tables, NOTES and PROFILES. NOTES has the columns 'user','date','subject','note', and 'share'. PROFILES has the columns 'user', and 'department'.

I want to display the date and subject for all notes which either belong to me or belong to others in my department who have marked the note as 'shared', i.e. both my notes and shared notes within the department would show at the same time.

The computer knows who I am already by $user, and where I work by $user_department.

Can someone provide me with the query. My attempt failed, as it repeated the subject many times. My attempt was:

Code:

$query = "SELECT a.date, a.subject FROM notes a, profiles b
WHERE a.user = \"$user\" OR a.shared = \"Y\" AND
b.department = \"$user_department\" ORDER BY a.subject";

I do see now that I am not linking the user in a to the user in b, but I am still a little lost.
Quote Reply
Re: [Lee] Help with query In reply to
Thanks, but I got it ... guess I was just having a dense moment :)