# `ij`, `ijf`

_Inner join_
```syntax
x ij  y     ij [x;y]
x ijf y     ijf[x;y]
```

Where

- `x` and `y` are tables
- `y` is keyed, and its key columns are columns of `x`

returns `x` and `y` joined on the key columns of `y`.
The result has one combined record for each row in `x` that matches a row in `y`.
```q
q)t:([]sym:`IBM`FDP`FDP`FDP`IBM`MSFT;price:0.7029677 0.08378167 0.06046216 0.658985 0.2608152 0.5433888)
q)s:([sym:`IBM`MSFT]ex:`N`CME;MC:1000 250)
q)t ij s
sym  price     ex  MC
-----------------------
IBM  0.7029677 N   1000
IBM  0.2608152 N   1000
MSFT 0.5433888 CME 250
```

In columns common to both tables, values from `y` replace values from `x`.
```q
q)([] k:1 2 3 4; v:10 20 30 40) ij ([k:2 3 4 5]; v:200 300 400 500;s:`a`b`c`d)
k v   s
-------
2 200 a
3 300 b
4 400 c
```

`ij` is a [multithreaded primitive](mt-primitives.md).

## `ijf`

With `ij`, a null in a matching record of `y` replaces the value in `x`.
`ijf` instead keeps the value from `x` where the value in `y` is null.
```q
q)show x:([]a:1 2;b:`x`y;c:10 20)
a b c
------
1 x 10
2 y 20
q)show y:([a:1 2]b:``z;c:1 0N)
a| b c
-| ---
1|   1
2| z
q)x ij y
a b c
-----
1   1
2 z
q)x ijf y
a b c
------
1 x 1
2 z 20
```

----

[Joins](joins.md)


_Q for Mortals_
[§9.9.4 Ad Hoc Inner Join](../learn/q4m/9_Queries_q-sql.md#994-ad-hoc-inner-join-ij)
