Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL inner join incorrect results
Message
From
02/10/2006 14:19:30
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01158594
Message ID:
01158646
Views:
28
Kevin,

Then there's some filter elsewhere

Try with a small subset to see what is happening

eg
select catalog.cat_type_code,catalog.cat_id, catalog.cat_title, catalog.cat_phase_code, catalog.cat_active_yn
FROM CATALOGFILE
where  cat_id in ( 1, 22, 33 )     && put in a few codes you know
&& look at the result set
&& then gradually build up by adding one condition at a time
Success,


>Well, I guess I thought it solved it, but it doesn't appear now that it did.
>
>It's not that it's filtering those rows from showing, they DO show, they just contain the wrong data in the cat_phase_code field. They are showing "PH1" instead of "CWT", but the record in the catalog table does contain the data "CWT" in that field.
>
>
>>You're welcome. It seemed to be the only thing that reduced the result set
>>____________
>>
>>>That seemed to be it. That makes sense, now that you brought that to my attention. Thanks!
>>>
>>>>>I have an inherited system with a SQL database, and in it is a stored procedure that has the following query:
>>>>>
>>>>>
>>>>>select catalog.cat_type_code,catalog.cat_id, catalog.cat_title, catalog.cat_phase_code, catalog.cat_active_yn,
>>>>>TEST_PROFILE.test_pro_status
>>>>>FROM CATALOG INNER JOIN TEST_PROFILE
>>>>>ON TEST_PRO_CAT_ID = CAT_ID
>>>>>where  cat_active_yn = 'Y'
>>>>>and test_pro_status = 'L'
>>>>>and cat_type_code in ('PRE', 'T')
>>>>>and cat_sponser_cd = 'DCF'
>>>>>
>>>>>
>>>>>The number of records returned is correct, but the field "cat_phase_code" should have one of two values, either "PH1" or "CWT". In the query results all cat_phase_code fields contain "PH1".
>>>>>
>>>>>I know it has something to do with the join, because if I remove it, the query returns the correct values per record.
>>>>>
>>>>>Does anything blatantly wrong stick out at anyone? I've been playing with it to no avail.
>>>>>
>>>>>Thanks!
>>>>>KP
>>>>
>>>>Kevin,
>>>>
>>>>Try to take the following out of your select
>>>>
>>>>and test_pro_status = 'L'
>>>>
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform