Hello All,
Sorry for the double post but I realized this topic would fit better in this forum.
Before this I'd never before needed to use the "LEFT JOIN" command, and unfortunately it's giving me some problems.
I have three tables setup as follows (note they are test tables for a prototype of a larger project):
user_table:
| UserID | Username | Password|
| 1 | julian | abcdef |
| 2 | test | test |
file_table:
| FileID | UserID | FileAccess |
| 1 | 1 | file1.txt|
| 2 | 1 | file2.txt |
| 3 | 2 | file2.txt |
list_table:
| ListID | FileName |
| 1 | file1.txt |
| 2 | file2.txt |
| 3 | file3.txt |
I want to run a query that will display all rows of "FileName" on the second column, and "FileAccess " on the second column IF FileAccess is equal to FileName AND UserID in TableB is equal to a variable which is given a value in a previous part of my program. (For this test it has been given the value two.)
This is my query:
This is what it returns:
FileName | FileAccess
file2.txt | file2.txt
This is what I WANT it to return:
FileName | FileAccess
file1.txt |
file2.txt | file2.txt
I've tried all types of variations of the query and even tried to make it a right join all without success. Any help with the query will be greatly appreciated.
Sorry for the double post but I realized this topic would fit better in this forum.
Before this I'd never before needed to use the "LEFT JOIN" command, and unfortunately it's giving me some problems.
I have three tables setup as follows (note they are test tables for a prototype of a larger project):
user_table:
| UserID | Username | Password|
| 1 | julian | abcdef |
| 2 | test | test |
file_table:
| FileID | UserID | FileAccess |
| 1 | 1 | file1.txt|
| 2 | 1 | file2.txt |
| 3 | 2 | file2.txt |
list_table:
| ListID | FileName |
| 1 | file1.txt |
| 2 | file2.txt |
| 3 | file3.txt |
I want to run a query that will display all rows of "FileName" on the second column, and "FileAccess " on the second column IF FileAccess is equal to FileName AND UserID in TableB is equal to a variable which is given a value in a previous part of my program. (For this test it has been given the value two.)
This is my query:
Code:
sql = "SELECT file_list.FileName, file_table.FileAccess FROM file_list " sql = sql & "LEFT JOIN file_table ON file_list.FileName = file_table.FileAccess " sql = sql & "WHERE file_table.UserID = 2"
FileName | FileAccess
file2.txt | file2.txt
This is what I WANT it to return:
FileName | FileAccess
file1.txt |
file2.txt | file2.txt
I've tried all types of variations of the query and even tried to make it a right join all without success. Any help with the query will be greatly appreciated.
Comment