title: MySQL join 2 tables A,B by id, where A.id is a substring of B.id
body: <p>I have 2 tables, 'Node' and 'Equipment'</p>
  <p>The Node Table has node id, name, and function. Each node is full of equipment, given in the Equipment table. The equipment id contains the node id + equipment designation text. So the node id is a substring of the equipment id. I want to be able to query what equipment a node has by using the node id in the equipment table.</p>
  <p>How can I structure a query to:</p>
  <p>&quot;Join the tables given the node id, Add the node longName column entry to each piece of equipment in the equipment table containing the node id (within its equipment id)&quot;</p>
  <p>Edit: This is not a duplicate question as it relies on the use of &quot;LIKE&quot;, which was not present in the other linked answer</p>
  <pre><code>Node table
  +--------------------------------------+------------+----------------+
  | id                                   | longName   | memberFunction |
  +--------------------------------------+------------+----------------+
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995 | North_Node | DGE            |
  | 182019b4-b2e7-307b-85c6-2a39001a54ff | South_Node | DGE            |
  | 1adf96c7-8e0d-35d9-9d00-1c0acf6c6f92 | East_Node  | ROADM          |
  | 1d14064f-6bd9-3d11-862f-abc25612d88f | West_Node  | ILA            |
  +--------------------------------------+------------+----------------+
  </code></pre>
  <pre><code>Equipment table
  +----------------------------------------------------+-------+------+
  | id                                                 | shelf | slot |
  +----------------------------------------------------+-------+------+
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21      |    21 | NULL |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_1    |    21 |    1 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_10   |    21 |   10 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_10_2 |    21 |   10 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_11   |    21 |   11 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_13   |    21 |   13 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_14   |    21 |   14 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_14_2 |    21 |   14 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_15   |    21 |   15 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_16   |    21 |   16 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_17_1 |    21 |   17 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_17_2 |    21 |   17 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_17_3 |    21 |   17 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_1_2  |    21 |    1 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_2    |    21 |    2 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_3    |    21 |    3 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_5    |    21 |    5 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_6    |    21 |    6 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_7    |    21 |    7 |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_9    |    21 |    9 |
  ........................
  
  </code></pre>
  <pre><code>Desired output table
  +----------------------------------------------------+-------+------+------------+
  | id                                                 | shelf | slot | longName   |
  +----------------------------------------------------+-------+------+------------+
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21      |    21 | NULL | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_1    |    21 |    1 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_10   |    21 |   10 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_10_2 |    21 |   10 | North_Node | 
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_11   |    21 |   11 | North_Node | 
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_13   |    21 |   13 | North_Node | 
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_14   |    21 |   14 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_14_2 |    21 |   14 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_15   |    21 |   15 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_16   |    21 |   16 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_17_1 |    21 |   17 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_17_2 |    21 |   17 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_17_3 |    21 |   17 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_1_2  |    21 |    1 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_2    |    21 |    2 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_3    |    21 |    3 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_5    |    21 |    5 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_6    |    21 |    6 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_7    |    21 |    7 | North_Node |
  | 15c6a1ef-ff1c-3486-bce9-8157906a2995::EQPT_21_9    |    21 |    9 | North_Node |
  .............................................
  </code></pre>