Title: SQL: convert Where clause to Inner Join
Tags: sql;oracle;inner-join
Question: I am trying to manipulate a query by converging to JOIN but it continues with the same errors.

```SELECT TRIM(T007.CUENTA) AS CUENTA, 
T007.IDENTCLI AS IDENTTIT, 
T013.IDENTCLI AS IDENTADIC, 
TRIM(T026.DESTIPT) AS DESTIPT, 
T043.PRODUCTO, T043.SUBPRODU, 
TRIM(T043.DESPROD) AS DESPROD, 
T175.CODESTCTA, 
TRIM(T175.DESESTCTA) AS DESESTCTA, 
T043.LINEAPR    
FROM MPDT007 T007, MPDT013 T013, MPDT043 T043, MPDT175 T175 ,MPDT026 T026 
WHERE T007.CUENTA = 000005433752 
AND T007.CUENTA = T013.CUENTA  
AND T013.NUMBENCTA = 2 
AND T013.CODENT = 0001      
AND T026.INDTIPT = 3 
AND T007.PRODUCTO = T043.PRODUCTO 
AND T007.SUBPRODU = T043.SUBPRODU 
AND T007.CODESTCTA = T175.CODESTCTA  
AND T043.LINEAPR = T175.LINEA 
AND T043.LINEAPR <&gt; 0003
```

to 

```SELECT TRIM(T007.CUENTA) AS CUENTA, 
T007.IDENTCLI AS IDENTTIT, 
T013.IDENTCLI AS IDENTADIC, 
T043.PRODUCTO AS PRODUCTO,  
T043.SUBPRODU AS SUBPRODU,  
TRIM(T043.DESPROD) AS DESPROD
FROM MPDT007 T007   
JOIN MPDT013 T013 ON (T013.CUENTA = T007.CUENTA AND T013.NUMBENCTA = 2 AND T013.CODENT = 0001)
JOIN MPDT043 T043 ON (T043.LINEAPR <&gt; 0001 AND T043.PRODUCTO = T007.PRODUCTO AND T007.SUBPRODU = T043.SUBPRODU) 
WHERE 
T007.CUENTA = 000005433752
```

The result of the following query does not show any fields.perform multiple variations of the inner join (left-right) with no apparent solution.

Thanks for your comments.

Comment: Your queries are not the same because of the parentheses, which change the way things are evaluated. One of your queries is very wrong, but without having the data you're going to need to inspect the results you're getting to figure out which one it is that isn't correct.

Comment: Check your join its in the wrong format.


Here is another answer: Try checking you inner join you put open and close parenthesis.

```SELECT TRIM(T007.CUENTA) AS CUENTA, 
       T007.IDENTCLI AS IDENTTIT, 
       T013.IDENTCLI AS IDENTADIC, 
       T043.PRODUCTO AS PRODUCTO,  
       T043.SUBPRODU AS SUBPRODU,  
       TRIM(T043.DESPROD) AS DESPROD
FROM MPDT007 T007   
JOIN MPDT013 T013 
   ON (T013.CUENTA = T007.CUENTA AND T013.NUMBENCTA = 2 AND T013.CODENT = 0001) --This is your ERROR
JOIN MPDT043 T043 
   ON (T043.LINEAPR <&gt; 0001 AND T043.PRODUCTO = T007.PRODUCTO AND T007.SUBPRODU = T043.SUBPRODU) --This is your ERROR
WHERE T007.CUENTA = 000005433752
```

tyr something like this:

```SELECT TRIM(T007.CUENTA) AS CUENTA, 
       T007.IDENTCLI AS IDENTTIT, 
       T013.IDENTCLI AS IDENTADIC, 
       T043.PRODUCTO AS PRODUCTO,  
       T043.SUBPRODU AS SUBPRODU,  
       TRIM(T043.DESPROD) AS DESPROD
FROM MPDT007 T007   
JOIN MPDT013 T013 
     ON T013.CUENTA = T007.CUENTA 
        AND T013.NUMBENCTA = 2 
        AND T013.CODENT = 0001
JOIN MPDT043 T043 
     ON T043.LINEAPR <&gt; 0001 
        AND T043.PRODUCTO = T007.PRODUCTO 
        AND T043.SUBPRODU = T007.SUBPRODU
WHERE T007.CUENTA = 000005433752
```

you just need to remove the open and close parenthesis because it treats it as one.


Here is another answer: You seem to be missing tables.  I think this is the equivalent:

```SELECT . . . 
FROM MPDT007 T007 JOIN
     MPDT013 T013
     ON T007.CUENTA = T013.CUENTA JOIN
     MPDT043 T043
     ON T007.PRODUCTO = T043.PRODUCTO AND
        T007.SUBPRODU = T043.SUBPRODU JOIN
     MPDT175 T175
     ON T043.LINEAPR = T175.LINEA JOIN
     ON T007.CODESTCTA = T175.CODESTCTA CROSS JOIN
     MPDT026 T026 
WHERE T007.CUENTA = '000005433752' AND   
      T013.NUMBENCTA = 2 
      T013.CODENT = '0001' AND      
      T026.INDTIPT = 3 
      T043.LINEAPR <&gt; '0003';
```

Note that ```T026``` does not appear to have a ```JOIN``` condition, only a filtering condition.

I added single quotes for the comparisons to numbers that start with a zero.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:12/17/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<sql><oracle><inner-join>', 'Title': 'SQL: convert Where clause to Inner Join', 'ViewCount': 56, 'id': 59366215, 'user_AboutMe': '', 'user_AccountId': 15163023.0, 'user_DisplayName': 'Frank', 'user_Reputation': 1.0, 'user_Views': 3.0, 'user_id': 11499990.0}}