Skip to main content

SQL QUERY

MySQL is a popular relational database management system used to store and manage data. Here are some common SQL queries with examples and explanations:


1. SELECT Query:

   - Example: `SELECT * FROM employees;`

   - Explanation: This query retrieves all columns (`*`) from the "employees" table, returning all rows.


2. WHERE Clause:

   - Example: `SELECT * FROM employees WHERE department = 'HR';`

   - Explanation: This query retrieves all columns from the "employees" table where the "department" column has the value 'HR'.


3. ORDER BY Clause:

   - Example: `SELECT * FROM employees ORDER BY salary DESC;`

   - Explanation: This query retrieves all columns from the "employees" table and sorts the result in descending order based on the "salary" column.


4. INSERT INTO Query:

   - Example: `INSERT INTO employees (name, age, department) VALUES ('John Doe', 30, 'IT');`

   - Explanation: This query inserts a new record into the "employees" table with specified values for the "name", "age", and "department" columns.


5. UPDATE Query:

   - Example: `UPDATE employees SET salary = 50000 WHERE department = 'Finance';`

   - Explanation: This query updates the "salary" column to 50000 for all rows in the "employees" table where the "department" column has the value 'Finance'.


6. DELETE Query:

   - Example: `DELETE FROM employees WHERE age > 60;`

   - Explanation: This query deletes all rows from the "employees" table where the "age" column is greater than 60.


7. JOIN Clause:

   - Example: `SELECT employees.name, departments.department_name FROM employees JOIN departments ON employees.department_id = departments.id;`

   - Explanation: This query retrieves the "name" column from the "employees" table and the "department_name" column from the "departments" table, joining them based on the "department_id" and "id" columns, respectively.


These are just a few examples of MySQL queries. Remember that SQL syntax may vary slightly depending on the specific database system you are using, but the principles remain consistent.

Comments

Popular posts from this blog

Microsoft Word 2010 Shortcut Key in Gujarati

Microsoft Word 2010 Shortcut key in Gujarati

Multi currency entry in tally

 In Tally, handling multi-currency entries allows you to record transactions involving foreign currencies. This feature is particularly useful for businesses that deal with international transactions or have accounts in different currencies. Here's how you can enable and use multi-currency entry in Tally: **Enabling Multi-Currency Feature**: 1. Go to Gateway of Tally (Home Screen). 2. Press F11 or click on "F11: Features" from the right sidebar. 3. In the Features screen, go to "F1: Accounting Features." 4. Under "Forex and Multi-Currency," set "Enable" to "Yes." 5. Save the settings. **Configuring Currency Rates**: 1. In the Gateway of Tally, click on "Accounts Info." 2. Select "Currencies" and then "Create." 3. Enter the currency details like symbol, name, formal name, etc. 4. Specify the "Standard Rates" for the currency against your base currency (usually your local currency). 5. Save the ...