What is SQL? How to use?

I already know at least that SQL has relationship with database, with the query of values in database.

But it is not clear What would be the SQL. What would you use this feature for? And how do you use SQL, for example in a user system?

Author: bfavaretto, 2014-06-28

3 answers

Basically basic

The information I am posting here is basic and may contain errors, anything can edit the answer or comment;)

Brief explanation

SQL is a database language, it has a syntax similar to that of English, if I were for example to query the Name of the user with ID 2 I could have a table like this:

+----+------------------+
| ID | Nome             |
+----+------------------+
| 1  | João Vitor       |
| 2  | Isabela Monteiro |
| 3  | John Snow        |
+----+------------------+

I would say for SQL Server to run the following command in the database:

SELECT Nome FROM `nomeDaTabela` WHERE `ID` = 2;

Which translating, would be:

SELECT COLUMN Nome FROM TABLE nomeDaTabela WHERE ID IS = 2

So I would select: Isabela Monteiro

Of course, I can do a lot more than read information, I can enter it, update it, delete it, merge it and much more.

SQL itself is just a syntax, there are several types of servers that interpret SQL, the most famous are MySQL, Postgre and MS SQL (Windows / Microsoft). Some functions and part of the syntax may vary from server to server, but the essence is the same.

Basically the scheme would be:

Meu código -> Declaração SQL (SELECT * FROM blabla) -> Servidor (MySQL)
-> Servidor interpreta e salva no banco de dados

There are several utilities in this, but as the name already says, the main purpose is to store data in tables in the database.

Login example

Let's assume I need a login for my app, here is my user table:

+----+------------------+--------------+
| ID | Nome             | Senha        |
+----+------------------+--------------+
| 1  | João Vitor       | senha1234    |
| 2  | Isabela Monteiro | goLfiNhO0    |
| 3  | John Snow        | uKnowNothing |
+----+------------------+--------------+

Now that I know my users, I need my basic login system:

First we take the information that the user sent:

Name: João Vitor

Password: password 1234

Now we compare the information with that of the database to check if the information that the application user sent is correct.

SELECT * FROM `tabelaUsuarios` WHERE `Nome`="João Vitor" AND `Senha`="senha1234"

The server, by default, will return the number of rows in the table it encountered with this condition, if the number of rows is greater than 0, we know that the login actually exists and authenticate it. If not, we ask the user to enter the credentials again.

Basic Info

I suggest you check http://www.w3schools.com/sql / ; is in English, but has a good basic tutorial for what you need.

 17
Author: Olimon F., 2017-07-16 04:56:58

SQL is the language that vc uses to make queries and inserts in relational database. Your question is quite basic and I advise you to study what is relational database and try to understand how it works. SQL is not a resource but a language. There are several types of database, SQLite, SQLServer, Oracle all use SQL language to do the operations.

Useful Links for study: http://pt.m.wikipedia.org/wiki/SQL

 4
Author: rochasdv, 2014-06-28 06:06:36

Database management systems were created to ensure the persistence, consistency and integrity of a system's data, a solution created around the 1970s and has been working well for the information I receive.

 0
Author: Motta, 2014-06-28 17:00:32