All pastes #46006 Raw Edit

Untitled

public sql v1 · immutable
#46006 ·published 2006-03-17 07:09 UTC
rendered paste body
mysql> select id,name,mac from computers where id='2339';+------+-------------+-------------------+| id   | name        | mac               |+------+-------------+-------------------+| 2339 | Sun Ray #63 | 00:03:BA:0D:EB:A5 |+------+-------------+-------------------+mysql> select * from networking_ports where device_on='2339';+------+-----------+-------------+------------------------+--------+-------------------+----------------+--------+| ID   | device_on | device_type | iface                  | ifaddr | ifmac             | logical_number | name   |+------+-----------+-------------+------------------------+--------+-------------------+----------------+--------+| 1521 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0E:FD:C1 |              0 | Port 0 || 1522 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0E:F9:82 |              0 | Port 0 || 1523 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0E:FD:A7 |              0 | Port 0 || 1524 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:AD:F5 |              0 | Port 0 || 1525 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0F:00:15 |              0 | Port 0 || 1526 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0F:00:15 |              0 | Port 0 || 1527 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:CF:B4 |              0 | Port 0 |+------+-----------+-------------+------------------------+--------+-------------------+----------------+--------+7 rows in set (0.00 sec)update networking_ports set ifmac=(select mac from computers where networking_ports.device_on=computers.id limit 1);mysql> select * from networking_ports where device_on='2339';+------+-----------+-------------+------------------------+--------+-------------------+----------------+--------+| ID   | device_on | device_type | iface                  | ifaddr | ifmac             | logical_number | name   |+------+-----------+-------------+------------------------+--------+-------------------+----------------+--------+| 1521 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 || 1522 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 || 1523 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 || 1524 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 || 1525 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 || 1526 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 || 1527 |      2339 |           1 | 100Mbps Ethernet (UTP) | N/A    | 00:03:BA:0D:EB:A5 |              0 | Port 0 |+------+-----------+-------------+------------------------+--------+-------------------+----------------+--------+-- Started with this but I was testing order and limit which can't be used in mutiple table updateupdate networking_ports,computers set networking_ports.ifmac=computers.mac networking_ports.device_on=computers.id;So 'Device_on' matches an ID in a table called computers.  I want to change all ifmac in networking_ports that match the first device_on to the computers.id