Mike Harrison
|
| Posted: 06/20/2002, 12:42 PM |
|
I have the following sql
SELECT tasks.priority_id, tasks.status_id, tasks.task_name, tasks.assigned_by, tasks.assigned_to
FROM tasks
WHERE tasks.assigned_by = " & session("UserID") & ";
but this doesn't work (Invalid SQL query). Using CC and ASP
THanks in advance
|
|
|
 |
Mike Harrison
|
| Posted: 06/20/2002, 12:46 PM |
|
Sorry, below is the 'right' sql
SELECT tasks.priority_id, tasks.status_id, tasks.task_name, tasks.assigned_by, tasks.assigned_to
FROM tasks
WHERE tasks.assigned_by = " & session("UserID") & " OR tasks.assigned_to = " & session("UserID") & ";
|
|
|
 |
Chris
|
| Posted: 06/21/2002, 1:38 PM |
|
Hi Mike,
What is the & "; at the end for? Which database are you using?
Thanks.
|
|
|
 |
Brent
|
| Posted: 06/21/2002, 3:01 PM |
|
Are you sure UserID are defined as session variables? If they aren't, then the
SQL Where clause ends up being:
WHERE tasks.assigned_by =
So it replaces the session("UserID") with an empty string. Most people would use
the ToSQL(session("UserID")) which will return "NULL" if the parameter is empty.
My recommendation is to put the SQL statement in a variable and then print the variable
just prior to executing the query. That will show you what is getting executed.
|
|
|
 |
Mike
|
| Posted: 06/22/2002, 2:38 AM |
|
To answer the first reply: I'm using MSAccess database and for the second reply: Yes I'm sure the session variables are correct.
Thanks
|
|
|
 |
Mike
|
| Posted: 06/22/2002, 2:40 AM |
|
To explain my question: I'm using the Tasks exemple of CC. The table has a field assigned_by and a field assigned_to. In both fields the userid is stored.
I only want to see the records from the user if his userid is stored in the assigned_by OR the assigned_to field.
Hope you can help me.
Thanks
|
|
|
 |
Ken Fischer
|
| Posted: 06/22/2002, 9:30 PM |
|
I believe that you are missing the single quotes around the generated
value for UserID (see below).
"SELECT tasks.priority_id, tasks.status_id, tasks.task_name, tasks.assigned_by, tasks.assigned_to
FROM tasks
WHERE tasks.assigned_by = '" & session("UserID") & "'
OR tasks.assigned_to = '" & session("UserID") & "'"
-Ken
|
|
|
 |
|