SQL query doubt [closed]

1

I've seen the following expression in an sql video:

(union select  1,2,3 ) 

What does it mean?

link video: link

    
asked by anonymous 06.02.2016 / 00:32

1 answer

4

The function of the UNION operator is to return the DIFFERENT RESULTS of 2 SELECTS or more (to also list repeated results is used UNION ALL )

An example of this would be to list all cities in a client table together with those in a provider

Example:

 SELECT cidade FROM Cliente UNION SELECT cidade FROM Fornecedor

If you have only 2 clients, 1 living in São Paulo and the other in Rio de Janeiro, and only 1 Provider, from São Paulo the query will return:

São Paulo > Rio de Janeiro

Using UNION ALL for the same data:

Example:

 SELECT cidade FROM Cliente UNION ALL SELECT cidade FROM Fornecedor


São Paulo São Paulo
Rio de Janeiro

video is about SQL INJECTION

A page that displays 3 data appears and the author uses UNION in a query string to display 1, 2, and 3 in place of the original data. Then it replaces the code to steal data and credentials.

    
06.02.2016 / 11:37