February 6, 2003 at 5:21 am
Hi
I need to create 2 roles for my timesheet database.
Managers - need view and ammend on all Engineers timesheets.
Engineers - need view and ammend on just their own timesheet.
Now for Managers I'm just giving them SELECT, INSERT, UPDATE, DELETE on my 2 created tables and just SELECT on all the default stuff. Is this ok?
For Engineers I'm trying to write a simple view like this:
SELECT Person.*, Task.*
FROM Person INNER JOIN
Task ON Person.PersonID = Task.PersonID WHERE ....
Can I use something like - WHERE PersonID = user ?
Thanks
February 6, 2003 at 5:34 am
No as is currently. The reason is both Person and TaskID has a PersonID field in it. What you need to do is instead of using * list all the column names and don't reference Task.PersonID in that list. Then you can call WHERE PersonID = ???? with your view. Anywhere else the names are the same in the 2 tables you need to provide a column alias.
Ex.
Person.Manager as Parson_Manager,
Task.Manager as Task_Manager
so that each has a unique name for the output and reference.
February 6, 2003 at 6:05 am
Thanks for the quick reply Antares686.
So is this better:
SELECT Person.PersonID, Person.Firstname, Person.Lastname,
Person.Department, Person.middlename, Task.TaskID,
Task.TimeFrom, Task.TimeTo, Task.Task, Task.TaskDate
FROM Person INNER JOIN
Task ON Person.PersonID = Task.PersonID
Where I don't reference Task.PersonID at all, or do I still include it but use the alias (Task.PersonID as Task_PersonID)
Also, can I use this phrase - WHERE PersonID = user or uid or something rather than actually using the PersonID number?
Thanks again. 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply