Questions tagged as 'sql'

1
answer

How to list every day between two dates for more than one record (Oracle)

I applied an orientation of another topic and it worked cool when you only have one record in the table with the range, but I had problems when the same record has more than one date range. Using the query below: select trunc(to_date(X.DT_E...
asked by 17.05.2018 / 12:09
2
answers

How to ignore accents in an SQL query?

How could I perform a query by ignoring words with letters that contain accents? Word Example: Olá, é, Lógica, Pão I tried to use the collate noaccents command as follows: select c.* from Curso c where c.Descricao like '%Logica%'...
asked by 25.07.2018 / 06:02
2
answers

Filters or Sorting, which should be the first when creating an index in the database

Given, for example, the following Query: SELECT ClienteId, Nome, DataNascimento, Cidade, Estado, DataCadastro FROM Cliente WHERE Estado = :Estado AND Cidade = :Cidade ORDER BY DataCadastro, DataNascimento DESC In terms...
asked by 28.10.2014 / 12:16
2
answers

INNER JOIN with two fields from the same table

I'm having a problem that I have not found a solution to date. I have 3 tables in MySQL: Units: containing store information. Orders: Contains the order information made by store01 for store02, both of which are listed in the units table....
asked by 29.01.2015 / 16:04
2
answers

Insert into multiple input fields in different tables [closed]

I have the fields of date, CNPJ, latitude, longitude, site, facebook, on the same screen, only they are 3 different tables, how do I give insert from them from the same button ?? I use to save information but not all fields are required....
asked by 20.09.2016 / 14:05
4
answers

Different ways to count record numbers in MySQL

There's a difference in performance if you do: //seleciona todos os itens da tabela $cmd = "SELECT * FROM produtos"; $produtos = mysql_query($cmd); //conta o total de itens $total = mysql_num_rows($produtos); instead of executing a query:...
asked by 23.01.2015 / 14:42
1
answer

MySQL sort too slow for results with many records

I have two tables, the first one is used to group the data of the second with some information about the set, in order to facilitate the pagination of the contents. Table 1: - id INT(11) NOT NULL UNSIGNED AUTO_INCRE...
asked by 30.04.2016 / 02:12
1
answer

How to maintain multiple connections to postgresql in Node.js?

I'm using Node.js in a task where I need to migrate data between two PostgreSQL databases. The idea is more or less as follows: Connect to Bank A. Connect to Bank B. Return all records of A. Insert all A's Registers not yet present in...
asked by 27.10.2015 / 14:05
3
answers

How to mount SELECT?

I have a Products table with: ProCodigo - Primary Key de Produto ProNome And another Price History table with: HisCodigo - Primary Key de Histórico HisData HisPreco ProCodigo - Foreign Key de Produto I need to mount a SELECT that bring...
asked by 22.01.2016 / 18:06
4
answers

BETWEEN requires arguments in ascending order? Because?

I have the following dummy table. I created the following query: SELECT * FROM ALUNOS WHERE IDADE BETWEEN 10 AND 15 Returns students A, C, and D. Now, because when I reverse the order in BETWEEN SELECT * FROM ALUNOS WHERE IDAD...
asked by 10.12.2015 / 16:13