content_image/796907.jpg
You can use the insert()  method with the values()  method to insert records into an existing relational table. The insert()  method accepts individual columns or all columns in the table. Use one or more values()  methods to specify the values to be inserted. 

## Insert a Complete Record 

To insert a complete record, pass to the insert()  method all columns in the table. Then pass to the values()  method one value for each column. For example, to add a new record to the city table in the world_x  database, insert the following record and press Enter  twice. 

mysql-py> db.city.insert("ID", "Name", "CountryCode", "District", "Info").values( None, "Olympia", "USA", "Washington", ’{"Population": 5000}’) 

The city table has five columns: ID, Name, CountryCode, District, and Info. Each value must match the data type of the column it represents. 

## Insert a Partial Record 

The following example inserts values into the ID, Name, and CountryCode columns of the city table. 

mysql-py> db.city.insert("ID", "Name", "CountryCode").values( None, "Little Falls", "USA").values(None, "Happy Valley", "USA") 

When you specify columns using the insert()  method, the number of values must match the number of columns. In the previous example, you must supply three values to match the three columns specified. 

## Related Information 

## 20.4.4.2 Select Tables 

•See TableInsertFunction for the full syntax definition. 

You can use the select()  method to query for and return records from a table in a database. The X DevAPI provides additional methods to use with the select()  method to filter and sort the returned records. 

MySQL provides the following operators to specify search conditions: OR  ( || ), AND  ( && ), XOR , IS , NOT , BETWEEN , IN , LIKE , != , <> , > , >= , < , <= , & , | , << , >> , + , - , * , / , ~ , and % . Select All Records 

To issue a query that returns all records from an existing table, use the select()  method without specifying search conditions. The following example selects all records from the city table in the world_x database. 

<img src='content_image/796907.jpg'>

mysql-py> db.city.select() +------+------------+-------------+------------+-------------------------+ | ID | Name | CountryCode | District | Info | +------+------------+-------------+------------+-------------------------+ | 1 | Kabul | AFG | Kabol |{"Population": 1780000} | | 2 | Qandahar | AFG | Qandahar |{"Population": 237500} | | 3 | Herat | AFG | Herat |{"Population": 186800} | ... ... ... ... ... 

## Note 

Limit the use of the empty select()  method to interactive statements. Always use explicit column-name selections in your application code. 

