SQLAI.ai provides a powerful and highly accurate SQL generator. Simply provide instructions in your preferred language for the SQL query or data you require, and it will generate the query instantly. Adding a database schema (i.e., data source) enhances accuracy.
Using the generator is straightforward; follow these steps:
When you have generated a query, you can click the helper tools above the query for additional functionality:
If you have connected to a database, you can run queries directly by clicking the run button () and display the results in a table:
Or in an AI-generated chart:
Click the refine button () to make adjustments to the generated query:
Click the format button () to format the SQL query:
Additionally, you can set custom formatting rules.
Click the save button () to save the query:
Saved queries can be private or public.
When you have chosen MongoDB as the target database engine on the settings page, it will generate the arguments used in the db.runCommand
function. For example, if you want to find a specific user from the users collection, you could write:
Get user with email john@doe.org
And you will get:
{
find: "users",
filter: { email: "john@doe.org" }
}
To use the above in your code, use it with the db.runCommand
:
const user = db.runCommand({
find: 'users',
filter: { email: 'john@doe.org' },
});
Generating the argument for db.runCommand()
makes it easy to use the generated queries in your own code and modify them as needed.
Tip: If you connect to your MongoDB database, you can run the queries directly via SQLAI.ai and get the data you need.
Generally, usage is fairly intuitive, but below are a few specific examples:
Here are examples of business intelligence questions to ask the generator using the Rental database schema:
Pseudo-SQL uses "SQL-lingo" in everyday sentences. Here are some examples:
Simple Select Query
Retrieve the names and email addresses of all customers from the `customers` table.
Conditional Query
Get the order IDs and order dates from the `orders` table where the order status is 'shipped'.
Aggregate Function
Calculate the total sales amount from the `sales` table for the year 2023.
Join Tables
List the product names and their corresponding supplier names by joining the `products` and `suppliers` tables.
Group By Clause
Show the number of employees in each department from the `employees` table, grouped by department.
Order By Clause
Fetch the top 5 highest-paid employees from the `employees` table, ordered by salary in descending order.
Insert Statement
Add a new record to the `customers` table with the following details: name 'John Doe', email 'john.doe@example.com', and phone '123-456-7890'.
Update Statement
Update the email address of the customer with name 'John Doe' to 'john.doe@example.com' in the `customers` table.
Delete Statement
Remove all records from the `sessions` table where the session date is before '2023-01-01'.
Complex Query with Subquery
Select the names of customers who have placed more than 5 orders, using the `customers` and `orders` tables.
movies
table even if the instructions only mention films
.On each generator you can hover the helper tool icon above the generated query to see the shortcut. And also use: