SQL Query Lookup

I want to filter a SQL Query on a table using the 2nd column of the selected item in a list.

SELECT a_LongName
FROM Employee
WHERE HomeLocation_ID =
{Root Container.Locations.data}[{Root Container.Locations.data},1]

This syntax gets accepted but the query fails with the following message:

Exception: Error running query:
SQLQuery(query=SELECT a_LongName
FROM Employee
WHERE HomeLocation_ID =
Dataset [4R ⅹ 2C][Dataset [4R ⅹ 2C],1], database=VehicleDb)@0ms
On: Main Window 3.Root Container.Table.data
caused by GatewayException: Incorrect syntax near ‘4R ⅹ 2C’.
caused by SQLServerException: Incorrect syntax near ‘4R ⅹ 2C’.

What syntax should I use?

Thanks,
Dave

Hi Dave,

I usually stick the value from the list into a dynamic property, then use the dynamic property in the query. That way, I’m pretty sure what value is going into my script.

Also, I noticed that you you are using the .data as your row pointer. I’m guessing you were wanting to use .selectedIndex

That worked great!

Thanks.