How To Make Sql Query

Table of contents:

How To Make Sql Query
How To Make Sql Query

Video: How To Make Sql Query

Video: How To Make Sql Query
Video: Best Way to Write Basic SQL Queries 2024, May
Anonim

SQL is a computer language for writing queries on tables in relational databases. Its versatility makes it possible to use the same operators in different DBMS, even to transfer program code from one to another without significant changes.

How to make sql query
How to make sql query

Instructions

Step 1

Databases are widespread in the computer environment, including they are used to create sites and blogs. The main advantage of this type of data storage is that it is structured along similar lines.

Step 2

For example, to change some of the same attribute for the elements of the same table, for example, to edit some of the blog posts, which have already grown to large sizes. In particular, change one phrase or word for another. In this case, you do not need to track all records and make changes manually, you just need to use an sql query.

Step 3

You don't have to be a programming guru to do sql queries. However, this will require certain knowledge and skills. For example, you need to understand the structure of the database, or at least that part of it that you have access to. Know the name of the tables, the required columns (columns), as well as the name and purpose of the language operators.

Step 4

Generally, for a non-professional programmer or blogger, basic operators are sufficient, which can be divided into two groups: data definition operators and data manipulation operators.

Step 5

The most commonly used data manipulation operators. These are select, insert, update and delete. These operators are used to work with data within a table or several tables and have the following constructions: select, …, from; - selection from the entire table; select, …, from where = and / or =; - selection from the table according to the conditions; select * from; - selection of everything from the table.

Step 6

insert into () values (); - adding a row with the specified field values to the table; insert into values (); - adding all fields to the table.

Step 7

update set =; - changing one field in all records of the table; update set = where =; - change when certain conditions are met.

Step 8

delete from; - deleting all records from the table; delete from where =; - deletion when certain conditions are met. If there are more than one conditions, then they are written separated by commas.

Step 9

Higher-level operators are available to database administrators. These are operators for creating, modifying and deleting database objects, namely the database itself, its tables, users, and so on. There are three such operators: create, alter and drop. create table (, …,); - table creation.

Step 10

alter table [add, modify, drop] column; - changing table fields (adding, modifying, deleting).drop table; - deleting a table. This operation succeeds if there are no links to other tables.

Recommended: