iannorthwood
Technical User
I have 3 tables: one holds details of task requests (T_Request), one holds application details (T_App) and the last holds application vendor details(T_Vendor), the last to avoid users trying to use non-standard or shortened names e.g. 'MS' instead of 'Microsoft'
I'm trying to create a query on T_Request which will return all requests with apps from a particular vendor. Relevant structure details are:
T_Request
=========
RequestID, AppID
T_App
=====
AppID, AppVendorID, AppName
T_Vendor
========
VendorID, VendorName
T_Request.AppID will contain numbers from T_App.AppID, T_App.AppVendorID will contain numbers from T_Vendor.VendorID.
So, I want a query which will allow users to enter a 'fuzzy' vendor name and see all requests for apps with that vendor:
"Show me all requests from a vendor whose name begins with 'Aspect'"
My attempt:
<code>
SELECT
T_Request.RequestID,
T_Request.RequestAppID,
T_Request.RequestedBy,
T_Request.RequestedOn,
T_Request.RequestRequiredBy,
T_Request.RequestStatusID,
T_Request.RequestPackagerID,
T_Request.RequestSignedOffOn,
T_Request.RequestSignedOffBy,
T_Request.RequestTypeID,
T_Request.RequestPriorityID,
T_Request.RequestReleaseLocation
FROM
T_Request,
T_App
WHERE
RequestAppID
=
(SELECT AppID FROM T_App WHERE AppVendorID = (SELECT VendorID FROM T_Vendor WHERE VendorName LIKE 'Aspect*'))
</code>
Would it help to rename the fields so that they match, e.g. rename T_App.AppVendorID to T_App.VendorID? I did that to avoid having to prefix field names with table names in queries used elsewhere but the project is at an early stage so it wouldn't be too much trouble to change them.
Lastly, please bear in mind that I am a complete SQL novice so would appreciate actual 'code' rather than "Use the SQL [blah] command"-type advice.
I'm trying to create a query on T_Request which will return all requests with apps from a particular vendor. Relevant structure details are:
T_Request
=========
RequestID, AppID
T_App
=====
AppID, AppVendorID, AppName
T_Vendor
========
VendorID, VendorName
T_Request.AppID will contain numbers from T_App.AppID, T_App.AppVendorID will contain numbers from T_Vendor.VendorID.
So, I want a query which will allow users to enter a 'fuzzy' vendor name and see all requests for apps with that vendor:
"Show me all requests from a vendor whose name begins with 'Aspect'"
My attempt:
<code>
SELECT
T_Request.RequestID,
T_Request.RequestAppID,
T_Request.RequestedBy,
T_Request.RequestedOn,
T_Request.RequestRequiredBy,
T_Request.RequestStatusID,
T_Request.RequestPackagerID,
T_Request.RequestSignedOffOn,
T_Request.RequestSignedOffBy,
T_Request.RequestTypeID,
T_Request.RequestPriorityID,
T_Request.RequestReleaseLocation
FROM
T_Request,
T_App
WHERE
RequestAppID
=
(SELECT AppID FROM T_App WHERE AppVendorID = (SELECT VendorID FROM T_Vendor WHERE VendorName LIKE 'Aspect*'))
</code>
Would it help to rename the fields so that they match, e.g. rename T_App.AppVendorID to T_App.VendorID? I did that to avoid having to prefix field names with table names in queries used elsewhere but the project is at an early stage so it wouldn't be too much trouble to change them.
Lastly, please bear in mind that I am a complete SQL novice so would appreciate actual 'code' rather than "Use the SQL [blah] command"-type advice.