SQL - Queries
SQL coins the term query as the name for its commands. Basically, all SQL code is written in the form of a query statement and then executed against a database. All SQL queries perform some type of data operation such as selecting data, inserting/updating data, or creating data objects such as SQL databases and SQL tables. Each query statement begins with a clause such as SELECT,UPDATE, CREATE or DELETE.SELECT queries are the most commonly used SQL commands, so let's take a look at a SELECT query that will return records from the orders table.
SQL Query Code:
USE mydatabase; SELECT * FROM orders;
SQL Query Results:
| id | customer | day_of_order | product | quantity |
| 1 | Tizag | 2008-08-01 00:00:00.000 | Pen | 4 |
Here's a look at a few different query types including a INSERT and SELECT query we will be covering in the next lesson, SQL Select.
SQL Query Examples:
-- Inserts data into a SQL Database/Table
INSERT INTO orders (customer,day_of_order,product, quantity)
VALUES('Tizag','8/1/08','Pen',4);
-- Selects data from a SQL Database/Table
SELECT * FROM orders;
-- Updates data in a Database/Table
UPDATE orders SET quantity = '6'
WHERE id = '1'







0 comments:
Post a Comment