Skip to content

CREATE VIEW statement

Work in progress

Note this feature is in beta version. If you have additional questions or issues reach out to us on Slack.

In MindsDB, the AI Table is a virtual table based on the result-set of the SQL Statement that JOINS the table data with the models prediction. The AI Table can be created using the CREATE AI table ai_table_name statement.

CREATE AI table ai_table_name as (
        p.model_column as model_column
    FROM integration_name.table_name as a
    JOIN predictor_name as p

Example view

The below table can be JOINED with the model trained from it as an AI Table.

number_of_rooms number_of_bathrooms sqft location days_on_market initial_price neighborhood rental_price
0 1 484 great 10 2271 south_side 2271
1 1 674 good 1 2167 downtown 2167

SQL Query for creating the home_rentals_model that predicts rental_price:

CREATE PREDICTOR home_rentals_model
FROM integration_name (SELECT * FROM house_rentals_data) as rentals
PREDICT rental_price as price;

Join the predicted rental_price from the model with the sqft, number_of_bathrooms, location from the table:

CREATE AI table home_rentals as (
        p.rental_price as price
    FROM mysql_db.home_rentals as a
    JOIN home_rentals_model as p