D
darson4eva
Good afternoon,
I have tried my best on this but am unable to figure it out.
---------------------------------------------------------------------
Scenario:
Table A contains only one column titled [District].
Let's assume that there are three rows here:
1) Bay Area Rapid Transit
2) San Diego Zoo
3) San Mateo
Table B contains other data with these fields:
[GeoCode] , [CountOfHourlyEmployees], [CountOfSalaryEmployees].
Let's assume that there are three rows here:
1) West Coast | CA | Bay Area Rapid Transit , 154, 205
2) CA | Southern | Bay Area Rapid Transit , 105, 206
3) Southwest | CA | San Diego Zoo, 358, 625
I am attempting to create a query that will return all values from Table B
that contain the string from Table A. This should be grouped by the value in
Table A
For example, I would expect my output to be:
Bay Area Rapid Transit, West Coast | CA | Bay Area Rapid Transit , 154, 205
Bay Area Rapid Transit, CA | Southern | Bay Area Rapid Transit , 105, 206
San Diego Zoo, Southwest | CA | San Diego Zoo, 358, 625
--------------------------------------------------------------------------------------------
This is the query that I'm using:
SELECT A.District,
B.GeoCode,
B.CountOfHourlyEmployees,
B.CountOfSalaryEmployees
FROM A, B
WHERE InStr(B.GeoCode, A.District)<>0;
In my results, I'm getting some of the data but not everything. I noticed
that if a value appears more than once in Table B, only the first record is
picked up.
Any suggestions?
I have tried my best on this but am unable to figure it out.
---------------------------------------------------------------------
Scenario:
Table A contains only one column titled [District].
Let's assume that there are three rows here:
1) Bay Area Rapid Transit
2) San Diego Zoo
3) San Mateo
Table B contains other data with these fields:
[GeoCode] , [CountOfHourlyEmployees], [CountOfSalaryEmployees].
Let's assume that there are three rows here:
1) West Coast | CA | Bay Area Rapid Transit , 154, 205
2) CA | Southern | Bay Area Rapid Transit , 105, 206
3) Southwest | CA | San Diego Zoo, 358, 625
I am attempting to create a query that will return all values from Table B
that contain the string from Table A. This should be grouped by the value in
Table A
For example, I would expect my output to be:
Bay Area Rapid Transit, West Coast | CA | Bay Area Rapid Transit , 154, 205
Bay Area Rapid Transit, CA | Southern | Bay Area Rapid Transit , 105, 206
San Diego Zoo, Southwest | CA | San Diego Zoo, 358, 625
--------------------------------------------------------------------------------------------
This is the query that I'm using:
SELECT A.District,
B.GeoCode,
B.CountOfHourlyEmployees,
B.CountOfSalaryEmployees
FROM A, B
WHERE InStr(B.GeoCode, A.District)<>0;
In my results, I'm getting some of the data but not everything. I noticed
that if a value appears more than once in Table B, only the first record is
picked up.
Any suggestions?