SQL

WHERE Clause | Database

Introduction WHERE clause is used to specify condition while retrieving, updating or deleting data from a table. When we specify a condition using the WHERE clause then the query executes only for those records for which the condition specified by the WHERE clause is true. Syntax WHERE clause is used [...]

2020-04-12T12:13:45+05:30Categories: Programming|Tags: , |

DISTINCT Statement | Database

Introduction In a table, a column may contain many duplicate values. DISTINCT keyword can be used to return only distinct values. It can be used with aggregates i.e. COUNT, AVG, MAX, etc. Syntax SELECT DISTINCT column_name FROM table_name; Above query returns only distinct values in the specified column. To find [...]

2020-03-14T20:34:09+05:30Categories: Programming|Tags: , |

ALTER Statement | Database

Introduction ALTER statement is used for altering the table structure. It can be used for Add a column to existing tableRename any existing columnChange datatype of any column or to modify its sizeDrop a column from the table Add New Column To add new column to existing table ALTER TABLE [...]

2020-03-14T20:34:09+05:30Categories: Programming|Tags: , |

DEFAULT and UNIQUE Constraint | Database

DEFAULT Constraint This constraint provides a default value for a column. Default value will be added to all new records if no other value is specified. Below example create a table set default value None for column phone. CREATE TABLE Person ( id INT PRIMARY KEY, first_name VARCHAR (50) NOT [...]

2020-03-14T20:34:09+05:30Categories: Programming|Tags: , |

NULL Value | Database

Introduction In database, NULL is used to indicate the absence of any data value. For example, at the time of recording the customer information, the email may be unknown, so it is recorded as NULL in the database. NULL is used to signify missing or unknown values. Comparison With NULL [...]

2020-03-14T20:34:09+05:30Categories: Programming|Tags: , |

Create and Delete Table | Database

Introduction Tables are used to store data in the database. Each table contains one or more columns. And each column has an associated data type that defines the kind of data it can store e.g., number, string. To create a new table, use CREATE TABLE statement. Use DROP TABLE statement [...]

2020-03-14T20:34:09+05:30Categories: Programming|Tags: , |

DELETE Statement in MySQL

Introduction DELETE statement in MySQL removes one or more rows in a table permanently. Use the WHERE clause to DELETE only specific records. Syntax DELETE FROM table_name WHERE condition; It will delete record from table table_name based on the condition passed to optional WHERE clause. To remove one or more [...]

2020-09-29T16:27:12+05:30Categories: Programming|Tags: , |

UPDATE Statement | Database

Introduction UPDATE statement is used to modify the existing rows in a table. It is used with WHERE clause to update only specific records. Syntax UPDATE table_name SET column1 = new_value1, column2 = new_value2, ... WHERE condition; To update data in a table Specify the table name in the UPDATE [...]

2020-03-14T20:34:10+05:30Categories: Programming|Tags: , |

INSERT Statement | Database

Introduction INSERT statement is used to add new rows of data to a table. There are two ways to insert record Inserting the data directly to a table.Inserting data to a table through a SELECT statement. Syntax Inserts a single row into an existing table. Specify values for all columns [...]

2020-03-14T20:34:10+05:30Categories: Programming|Tags: , |

ORDER BY and OFFSET Clause | Database

Introduction ORDER BY clause is used in a SELECT statement to sort results either in ascending or descending order. By default ORDER BY sorts the data in ascending order. Use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order. OFFSET [...]

2020-03-14T20:34:10+05:30Categories: Programming|Tags: , |
Go to Top