Answer the question
In order to leave comments, you need to log in
How to select data depending on id?
how to convert queries like
SELECT "F_Value" FROM "SC_Wonder"."T_Passport" WHERE "ID_Product" = 2
SELECT "F_Value" FROM "SC_Wonder"."T_Passport" WHERE "ID_Product" = 3
into one so that I specifically know what the first number is will be the value with id 2 , the second with 3 and so on?
UPD
SELECT "F_Value" FROM "SC_Wonder"."T_Passport" WHERE "ID_Product" IN (2,3) ORDER BY ID_Product;
and if there is no value with id 2, how to return zero?
I can't guarantee that the ids will be strictly larger. you need to know that an element with a certain id will come in a strictly defined account or null will come
Answer the question
In order to leave comments, you need to log in
If I understand you correctly, then:
SELECT /* v.id, */ "F_Value"
FROM (VALUES (1), (2)) v(id)
LEFT JOIN "SC_Wonder"."T_Passport" p on v.id = p.ID_Product
ORDER BY ID_Product;
ID_Product
. Then, with the help of LEFT JOIN, existing records are selected. For non-existent fields, they will remain filled with nulls. If you uncomment, v.id
, you will see which ones ID_Product
have no values.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question