USING
Example
Section titled “Example”SELECT * FROM Employees;Output
Section titled “Output”| ID | Name | Department ||----|------|------------|| 1 | Amy | HR || 2 | Ben | Finance || 3 | Carl | IT |Explanation
Section titled “Explanation”In this SQL statement, SELECT * FROM Employees; is executed, which selects all the data from the Employees table. The ‘Output’ section shows the table displaying the result of the previous SQL statement. The table includes columns ‘ID’, ‘Name’, ‘Department’. The rows show the data of each employee in the ‘Employees’ table.
Example
Section titled “Example”CREATE TABLE Employees ( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50));INSERT INTO Employees (ID,NAME,AGE,ADDRESS) VALUES (1, 'Tom', 25, '1234 Main St');SELECT * FROM Employees;Output
Section titled “Output”| ID | NAME | AGE | ADDRESS ||----:|:----:|:---:|:-----------:|| 1 | Tom | 25 | 1234 Main St|Explanation
Section titled “Explanation”The SQL code defines a table ‘Employees’ and inserts a record into it. The output shows the resulting table as rendered in markdown, with one record for employee ‘Tom’.
Example
Section titled “Example”SELECT 'Hello, World!' AS Greeting FROM dual;Output
Section titled “Output”GREETING----------------Hello, World!Explanation
Section titled “Explanation”The SELECT statement retrieves values from the database. Here, a string ‘Hello, World!’ is selected and given the alias Greeting. The FROM clause indicates the table where the SQL statement will look for the data. In Oracle, Dual is a special one-row, one-column table present by default. The output is a single record with a single column named Greeting that contains the string ‘Hello, World!’.
Example
Section titled “Example”Markdown:
SELECT * FROM Employees WHERE Salary > 50000;Output
Section titled “Output”Markdown:
| Employee_ID | First_Name | Last_Name | Salary |
|---|---|---|---|
| 3 | John | Doe | 60000 |
| 5 | Jane | Smith | 75000 |
Explanation
Section titled “Explanation”The SELECT command is used to select data from a database. Here, it selects all the fields (*) from ‘Employees’ table where the ‘Salary’ field is greater than 50000. The result is a table that includes rows for ‘Employee_ID’, ‘First_Name’, ‘Last_Name’ and ‘Salary’ where the salary is more than 50000.