Alright...
let's see what I can do to explain this.
I have a base table that contains the following type of information:
recid (int)
controlnumber (string)
status (int)
tablename (string)
... other non-essential stuff.
Now, table 2 contains other info:
recid (int)
controlnumber (string) <--- this is the link btwn the two
incidentlocation (string)
incidentdate (datetime)
... etc etc
I need to join these 2 tables together to get information into a grid. However, table 2 may change on each record for number 1, meaning sometimes the information from table 1 must be linked to a table 2 called fdddata, sometimes its called fdddata_eht, etc.
Using a static SQL statement, I am doing the following:
select ts_central.status, ts_central.controlnumber,
ts_central.authorid, ts_central.datesubmitted,
fdddata.incdate, fdddata.incloc, fdddata.recid
FROM ts_central, fdddata WHERE ts_central.controlnumber =
fdddata.controlnumber and (status = 3 or status = 5)
and ts_central.authorid = 'csutton'
Again, where fdddata is shown above, sometimes it would be fdddata, sometimes fdddata_eht, etc. depending on the tablename from table 1.
I have no problem using a stored procedure if that would help, but I have no idea where to begin.
THANK YOU!!!!!!!!!!

I have a base table that contains the following type of information:
recid (int)
controlnumber (string)
status (int)
tablename (string)
... other non-essential stuff.
Now, table 2 contains other info:
recid (int)
controlnumber (string) <--- this is the link btwn the two
incidentlocation (string)
incidentdate (datetime)
... etc etc
I need to join these 2 tables together to get information into a grid. However, table 2 may change on each record for number 1, meaning sometimes the information from table 1 must be linked to a table 2 called fdddata, sometimes its called fdddata_eht, etc.
Using a static SQL statement, I am doing the following:
select ts_central.status, ts_central.controlnumber,
ts_central.authorid, ts_central.datesubmitted,
fdddata.incdate, fdddata.incloc, fdddata.recid
FROM ts_central, fdddata WHERE ts_central.controlnumber =
fdddata.controlnumber and (status = 3 or status = 5)
and ts_central.authorid = 'csutton'
Again, where fdddata is shown above, sometimes it would be fdddata, sometimes fdddata_eht, etc. depending on the tablename from table 1.
I have no problem using a stored procedure if that would help, but I have no idea where to begin.
THANK YOU!!!!!!!!!!