This topic is locked

custom SQL questions

1/26/2008 1:02:58 PM
ASPRunnerPro General questions
T
trumpet author

I'm trying to figure out a way to add /edit/view locations per attorney in a database. I plan to include a link on teh attorney profile to "Add Locations" to show which locations the attorney practices.
I tried creating a custom SQL query as follows...
select * from locations

INNER JOIN attorneys_by_locations ON locations.location_id = attorneys_by_locations.location_id

where attorney_id =" & attorney_id
The attorneys_by_locations table includes 2 fields... attorney_id & location_id only.

I need to make the sql query dynamic based on the attorny_id which can be fed from the attorney profile section. How do I pass the attorney_id to this query? I also need to be able to let them add/delete the locations, too.
Thanks for your direction...
-LWTrumpet

Sergey Kornilov admin 1/27/2008

You can use Before SQL Query event and the following code:

strWhereClause = whereAdd(where, "attorney_id =" & Session("attorney_id"))


Make sure Session("attorney_id") is populated with correct attorney id (not sure where it comes from).