Subject | Re: DEAD LOCK ON SQL |
---|---|
Author | iananewby |
Post date | 2002-06-11T15:56:36Z |
Hi Burak,
Firebird is poor at dealing with sub-selects. Basically the sub
select fires for every record in the main table. Two alternatives
are as follows:
Use EXISTS in place of IN
SELECT U.URUN_KUTUK_ID
, U.CARIID
, U.MARKAID
, U.URUN_KOD
, U.URUN_AD_TR
, U.URUN_AD_EN
, U.GTIP
FROM URUN_KUTUK U
WHERE URUN_KOD IN
(SELECT I.GM_PART_NUMBER
FROM INVOICE_DETAIL I
WHERE I.INVOICE_MASTER_ID=437 and I.GM_PART_NUMBER = U.URUN_KOD)
Or use joins
SELECT U.URUN_KUTUK_ID
, U.CARIID
, U.MARKAID
, U.URUN_KOD
, U.URUN_AD_TR
, U.URUN_AD_EN
, U.GTIP
FROM URN_KUTUK U
JOIN INVOICE_DETAIL I
ON I.GM_PART_NUMBER = U.URUN_KOD
WHERE I.INVOICE_MASTER_ID=437
Hope that helps
Ian Newby
Firebird is poor at dealing with sub-selects. Basically the sub
select fires for every record in the main table. Two alternatives
are as follows:
Use EXISTS in place of IN
SELECT U.URUN_KUTUK_ID
, U.CARIID
, U.MARKAID
, U.URUN_KOD
, U.URUN_AD_TR
, U.URUN_AD_EN
, U.GTIP
FROM URUN_KUTUK U
WHERE URUN_KOD IN
(SELECT I.GM_PART_NUMBER
FROM INVOICE_DETAIL I
WHERE I.INVOICE_MASTER_ID=437 and I.GM_PART_NUMBER = U.URUN_KOD)
Or use joins
SELECT U.URUN_KUTUK_ID
, U.CARIID
, U.MARKAID
, U.URUN_KOD
, U.URUN_AD_TR
, U.URUN_AD_EN
, U.GTIP
FROM URN_KUTUK U
JOIN INVOICE_DETAIL I
ON I.GM_PART_NUMBER = U.URUN_KOD
WHERE I.INVOICE_MASTER_ID=437
Hope that helps
Ian Newby