I am having problems writing a query - I am not even sure if this is possible to do. Here is how in this example the 2 tables look:
TBL_PART_DM
-----------
PART_ID (KEY)
PART_IMG
PART_NAME
TBL_PART_LOC
------------
PART_ID (KEY)
PART_LOC (KEY)
In this example, lets say that somebody searches by PART_NAME. What I want is to write a query that pulls back everything from the first table, as well as how many records there are in the second table for that part. My knowledge of agrovate functions isn't that great, but I am still not seeing a way to do this?
T2 can only return one value since I am using an agrovate function, so I can't return a PART_ID along with the count. If that were the case, I could easily join them by saying WHERE T1.PART_ID=T2.PART_ID.
Is there even a way to do this?
Thanks!
TBL_PART_DM
-----------
PART_ID (KEY)
PART_IMG
PART_NAME
TBL_PART_LOC
------------
PART_ID (KEY)
PART_LOC (KEY)
In this example, lets say that somebody searches by PART_NAME. What I want is to write a query that pulls back everything from the first table, as well as how many records there are in the second table for that part. My knowledge of agrovate functions isn't that great, but I am still not seeing a way to do this?
Code:
SELECT DISTINCT
T1.PART_ID,
T1.PART_NM,
T1.PART_IMG,
T2.PART_COUNT
FROM
TBL_PART_DM T1,
(
SELECT
COUNT(PART_LOC) AS PART_COUNT
FROM
TBL_PART_LOC
) T2
WHERE
PART_NM = 'SOME SEARCH STRING'
T2 can only return one value since I am using an agrovate function, so I can't return a PART_ID along with the count. If that were the case, I could easily join them by saying WHERE T1.PART_ID=T2.PART_ID.
Is there even a way to do this?
Thanks!