SQL query is what?
Databases allow not only to conveniently store large amounts of data, but also to quickly obtain the desired information. To do this, use a special command called a query.
This special string reference to the database, which reflects the fields (data particles) and the conditions by which this information must be provided.
The logic of compiling a data request from the database onmost programming languages are as simple as possible. To obtain information, you need to specify the management system that is configured for a particular storage, six basic parameters:
- the names of the tables from which you want to collect data;
- fields that you want to return;
- links between tables;
- conditions of sampling (if necessary);
- Auxiliary (sorting, presentation methods, restrictions and others).
Thanks to this structure, usersit is enough to understand only the structure of the desired query, after which it will be very easy to implement it "on paper". The reverse scheme also works - in order to understand what information is obtained by this or that command, it is necessary to know the basics in order to understand the query. This has made the language of SQL queries very popular among IT professionals and among those who want to master the difficult science of programming.
The language of SQL programming is flexible, sofor various purposes, you can modify the query. This may be due to the peculiarity of the database architecture that will affect the execution time of the request, the prevention of possible problems at a certain stage of work, and the legibility of the result obtained.
Compared to most other languagesprogramming, SQL-queries always return a clearly structured result in the form of a table. Therefore, when developing tools that require active work with large arrays of data, a specialized module is embedded in the code of the program, which ensures a fast and accurate exchange of information with the database, which can increase the speed of work up to several times, especially when users work.
In addition to the pluses, there is one significanta negative feature of the SQL query. It's working with fields that have the same name. In this case, it is necessary to control the aligned communication as clearly as possible, to specify independently from which table the data should be taken.
Consider the simplest query to the database onexample of the SQL language. Suppose that there are two tables that hold the unit of measurement of the currency - "Currency", and the money rate for the past 7 days - "Course". To execute a request for quotes for a particular currency, it is enough to execute the following command:
SELECT a.Date, a.Course FROM Rate a, Currency b WHERE a.ЕИ_id = b.id AND (b.Money Unit = "rub")
The result of the query is a table of two columns,which will contain data on the date and currency rate for each of the days for the exchange of the ruble. Due to the ease of modifying the query, just change the fields that you want to retrieve. In particular, to check the correctness of the upload, you can add a monetary unit to the list of output columns.