I have a view that uses select statements to populate a few of the fields. I can select all of the data just fine normally, but there seems to be a problem when I try to select one of the fields created by the sub-select statements more than once in the same SQL statement. The other strange thing about it is that it works fine if I'm select from just the view by itself or joined with one or two other tables, but not with the four that I'm trying to join on.
For example,
Code:
SELECT z.spouse_personid, z.spouse_personid
FROM xxdv_personmaster_v z
works fine, but after I add on the other tables that I want to join with it, it stops working, unless I only have 1 "spouse_personid". The fields from the view that aren't created from sub-selects work just fine multiple times.
I need to have this field selected multiple times to be able to put it in 4 different functions in the same SQL statement, but only one function works at a time. Each function returns almost instantaneously by itself, but any two or more just hang indefinitely.
A quick fix that I used was to put this in for each function:
Code:
(SELECT z2.spouse_personid
FROM xxdv_personmaster_v z2
WHERE z2.person_id = z.person_id)
That seems to work and do it quickly, but I feel like there should be a better way.
Anybody else had any similar problems?
Thanks