How to join two tables in two fields, provided that the second field of the second table can sometimes be null (in this case, the join is needed only in the first field)? 1 table:
поле1 | поле2 ------------ type1 | cat1 type1 | cat2 type1 | cat3 2 table:
поле1 | поле2 ------------- type1 | cat1 type1 | type1 | cat2 Those. if field2 is not cat2 or cat1, then joining only by field1 (i.e., for all categories except 1 and 2, the same values) Result according to Chad's proposal
поле1 | поле2 ------------ type1 | cat1 type1 | cat2 type1 | type1 | cat3
on (a.field1=b.field1 and (a.field2=b.field2 or b.field2 is null))? - ChadLEFT JOINjust suits you in this case. - Vadim Ovchinnikov