1

ArcGIS Pro 3.0.2

Is it possible to use the column of table in my Project to filter a query using the make query layer tool?

I have a table of events in my project with a location_id column, and I want to left join in my Locations table by location_id from different database. I want to only pull in locations that exist inside of my event table in the project so that I'm not loading the entire locations table.

Something like:

SELECT *
FROM location_tbl
WHERE location_tbl.id IN (<id_column_of_table_in_my_Pro_Project>)

I see this doc here about query parameters, but I don't see anything about passing in a column from an existing table as a parameter.

The data comes from two different SDE connection files to an MS SQL Server database.

4
  • 1
    If the objects are in the same source workspace, you could do a subquery (WHERE col1 in (SELECT col1 FROM table2 WHERE col2 = testcase)). Without more info about the data sources, it's difficult to assist. Commented Nov 1, 2022 at 1:02
  • Added to question. It's two different SDE connections. As far as I am aware, I don't think it's possible to query two different databases at the same time. Commented Nov 1, 2022 at 15:23
  • 2
    You can do a Join, but it's way more efficient to propagate a clone of the ancillary data into the GIS database, and use the database to do the join/subselect. Commented Nov 1, 2022 at 16:07
  • ahh yea currently I just pull in a few years of data that I know will contain the records I need then do a join, but was hoping I could just add the filter to the query directly. Commented Nov 1, 2022 at 22:16

1 Answer 1

0

you can do a join over two databases if the are on the same MS SQL-Server, ex.

SELECT 
tb_1.*,
tb_2.*
FROM [database_1].[table_schema].[table_name_1] tb_1
JOIN [database_2].[table_schema].[table_name_2] tb_2 ON tb_1.id = tb_2.id

you need the permission to access the database and the specified table

2
  • Unfortunately they are on different servers Commented Nov 9, 2022 at 16:23
  • no problem please read: link Commented Nov 10, 2022 at 17:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.