1
I have a select that is being done with several Ner Join. However one of the time clauses returns empty or time returns full. We already know the reason for the void but we don’t know how to get around the situation.
We can evaluate the value if it returns full follows the full value if it returns empty returns a value as example 99999.?
as follows
SELECT
TLIPS.LGORT AS "Deposito" ,
TLIPS.CHARG AS "Lote" ,
TLIPS.MATNR AS "codProduto" ,
TLIPS.ARKTX AS "DescProduto" ,
TLIPS.ERDAT AS "DataRemessa" ,
TLIPS.VBELN AS "NRemessa" ,
L.ERZET AS "HoraRemessa" ,
L.INCO1 AS "Modalidadevenda" ,
L.BTGEW AS "QuantidadeCarga" ,
K.NAME1 AS Cliente,
CAST(COALESCE(K.KUNNR, '0') AS VARCHAR) AS cod_cliente,
CONCAT(REPLICATE('0', 18 - LEN(TLIPS.MATNR)),RTRIM(TLIPS.MATNR)) as codsasf,
V2.TEXT2 AS "PlacaCarreta",
LF.NAME1 AS "Transportadora"
FROM LIPS AS TLIPS
INNER JOIN MARA AS M ON M.MATNR = TLIPS.MATNR
INNER JOIN LIKP AS L ON L.VBELN = TLIPS.VBELN
INNER JOIN KNA1 AS K ON K.KUNNR = L.KUNNR
INNER JOIN VTTP AS V ON V.VBELN = TLIPS.VBELN
INNER JOIN VTTK AS V2 ON V2.TKNUM = V.TKNUM
INNER JOIN LFA1 AS LF ON LF.LIFNR = V2.TDLNR
WHERE TLIPS.VBELN = XXXXXXXXX
From what I understand you want to return the result even if there is no relation, in this case you need to search on others joins, example: left Join, right Join and etc.. gives a look here: http://www.bosontreinamentos.com.br/mysql/mysql-left-e-right-join-consultar-dados-em-duas-ou-mais-tabelas-30/
– Raphael Godoi
what is the database?
– Ricardo Pontual
first, it could circumvent the value if it were a
left
orright
Join, ainner
will only bring values that exist in the two tables, so it seems to me a little confused what you wrote, can explain better? second, it is possible to resume yes a value in place of null, but as of this, withinner join
should not happen, unless it is a field that is not related, hence it is simple, but needs to tell which database is using, because the functions used to treat this are different– Ricardo Pontual
To load a default, I have here an example explanation of another post for various database engines, ISNULL()
– Ernesto Casanova