Questions tagged as 'query'

2
answers

Why does the if or case test not work in this subquery?

I'm trying to run the following subquery inside a view: (SELECT if(idnotas > 0, "não", "sim") FROM notas WHERE vendas_idvendas = p.vendas_idvendas ORDER BY idnotas DESC LIMIT 1 ) as primeiraFatura, Howeve...
asked by 27.12.2018 / 12:49
1
answer

Bring "child" records count next to all table records

How do I count how many "children" that row has, and at the same time list all records in the table? I have the categorias table, with the following data: _________________________________ | id (PK) | nome | id_pai (FK) | --------...
asked by 11.03.2015 / 15:52
1
answer

Search ignoring accent in AWS CloudSearch

I'm using AWS Cloudsearch, and my question is about how I perform a simple search, such as "bone", and it returns the records that contain "cap", or "tennis" and return the records with "sneakers". I read in Amazon's documentation that it tre...
asked by 14.07.2014 / 19:08
1
answer

Update Query with select for Procedure

I'm trying to do a query that will enter a procedure but I'm not having success, the query looks like this: UPDATE sca_lotacao AS t0 SET t0.ativo = 0 WHERE ( SELECT * FROM sca_pessoa AS t1 RIGHT JOIN sca_lotacao A...
asked by 08.12.2014 / 19:03
2
answers

Query Select Option PHP

How to make a query with select option that the user can choose? No frontend: <form method="post" action="Procurarquery.php" enctype="multipart/form-data"> <span class="LABEL4CSS" id="LABEL4">Estado</span> <sel...
asked by 25.03.2014 / 18:44
1
answer

Select with subquery to pick up previous record

I have a structure of records of user readings by reference. According to data below. SELECT L.LeituraID, L.UsuarioID, L.Referencia, L.Leitura FROM Leituras AS L |-----------|-----------|------------|---------| | LeituraID | UsuarioID | Refe...
asked by 21.11.2018 / 18:28
1
answer

List users' phones from a join without duplicating the rows

Good evening, Well, I have the following problem: I need to join in two tables, USER and CONTACT. Each user has more than one contact (Phone), so when I 'm ready the data it returns me "duplicate" lines with different phones because, EX:...
asked by 03.01.2019 / 03:25
0
answers

How to allow duplicate value of a key in SQL?

I need the Process_Number and RecipeNumber keys to be able to receive values that already exist in the table. for example: Id = 1, Numero_Processo = 1, Numero_Revisao = 1 Id = 2, Numero_Processo = 1, Numero_Revisao = 2 Id = 2, Numero_Proce...
asked by 19.06.2018 / 17:02
4
answers

The WHERE clause order interferes with performance?

Recently I did tests on a database with a query using two clauses where AND. I noticed that there was a significant difference using clause A before B and vice versa. Intuitively, it would be faster to use FIRST the more restrictive criterion...
asked by 22.12.2014 / 19:01
0
answers

Get Directory and number in a string in an irregular expression

I have a table that has all the address in a single column, but it is irregular. Here are some of the following: BR 459 KM 153 RODOVIA ITAJUBA MF KM 05 Rodovia MG353 2Km 55 RUA 37 QUADRA 4 LOJA 611 E 1621 Rua 13 de Maio 71C RUA 106 Nº07 RUA...
asked by 14.05.2018 / 20:25