- 1). Open MySQL, connect to the database and open the command line interface.
- 2). Type "UPDATE plane JOIN passengers ON plane.seat = passengers.seat SET plane.occupied = 'Yes' WHERE passengers.name = 'Jim';" into the command line.
- 3). Press the "Enter" key to execute the query. MySQL will find all records in the passengers table that match "Jim" in the name column. It then locates all records in the plane table that have matching data in both tables' "seat" fields. MySQL then updates the records in the plane table to show that the seats Jim owns are now occupied. For example, if Jim buys seats 10 and 11 in the passengers table, this query will change the records for seats 10 and 11 in the plane table to reflect that those two sears are now occupied.
- 4). Type "SELECT * FROM table1" and press "Enter" to execute the query. Examine the results.
previous post