I am currently writing a sql script to return data if a user searches by certain criteria
*Supplier
*Approver
*Capturer
I have 2 tables which are joined
1 users/supplier
the users belong to a group which would determine if they are approver or capturer
Groupid Description
1 approver
2- Capturer
now the issue i am having is when trying filter data
so if the user wants to search for a supplier and an approver but limit the capturer i have a slight issue.my script is in the what have i tried below.
How could i improve my script
What I have tried:
Select Supplier.id,Supplier.SupplierDescription,User.Username Approver,''capturer
from supplier,user
where user.groupid = 1
Union all
Select Supplier.id,Supplier.SupplierDescription,''Approver,user.Username Capturer
from supplier,user
where user.groupid = 2
Now if the user decided they would like to search for all suppliers and 1 approver and all capturers
this is the script i currently have
Select Supplier.id,Supplier.SupplierDescription,User.Username Approver,''capturer
from supplier,user
where user.groupid = 1
and user.Userkey = 150
Union all
Select Supplier.id,Supplier.SupplierDescription,''Approver,user.Username Capturer
from supplier,user
where user.groupid = 2
and supplier.id in(Select Supplier.id
from supplier,user
where user.groupid = 1
and user.Userkey = 150)