I have the below SQL Server tables:
Asset Table
+---------+-----------+------------+
| AssetID | AssetName | LocationID |
+---------+-----------+------------+
Location Table
+-------------+---------------+------------------+
| LocationID | LocationName | SubLocationName |
+-------------+---------------+------------------+
How can I return results where the Assets Table LocationID = Location Table LocationID but also append the corresponding LocationName and SubLocationName as extra columns?
Assets Table
+---------+-----------+------------+
| AssetID | AssetName | LocationID |
+---------+-----------+------------+
| 1 | Asset1 | 123 |
+---------+-----------+------------+
Location Table
+------------+--------------------+----------------------+
| LocationID | LocationName | SubLocationName |
+------------+--------------------+----------------------+
| 123 | Area1 | Sub1 |
+------------+--------------------+----------------------+
would return:
+--------+-------+------+
| Asset1 | Area1 | Sub1 |
+--------+-------+------+
Thanks Paul.