Questions tagged as 'select'

6
answers

How to count the number of clients that have returned from one year to the other through SQL?

I have a Serviços(Nro_Serv, Data, Cliente, Valor) table and would like to get customers who did service with me in a year X (ex: 2011) and who also did in a year Y (ex: 2012). I tried to use COUNT(*) and then GROUP BY Cliente HA...
asked by 20.03.2014 / 18:29
2
answers

INNER JOIN with equal fields in a table - Error: # 1066 - Not unique table / alias: 'tb_user' [duplicate]

I have 3 tables as follows: Intb_user,Ihavetwotypesofusers(buyer,seller)inanENUMfieldtodifferentiatetheusertype.IntheshoppingcartIhavetheuserIDs,product,andtransactionnumber.Ilink2timestotb_usuariotoknowwhoboughtandwhosold.IwanttoperformaS...
asked by 27.11.2016 / 19:33
1
answer

How to style, with CSS, a SELECT that is inside PHP?

<?php include "conexao.php"; $sql = "select * from categorias"; $dados = pg_query($sql); $resposta = ""; while($linha = pg_fetch_array($dados)){ $nome_categoria = $linha["nome_categoria"]; $resposta .= "&...
asked by 22.10.2014 / 01:57
2
answers

View with double SELECT from the same table

I need to mount a VIEW with three fields, but one depends on the other to be calculated (two of them are from the same table in different lines I need to "link" them), how do I add those fields in one place? The select's are as follows: SELECT...
asked by 23.04.2018 / 18:08
2
answers

How to select in a table as if it were two registers

In the person table you have the following information ID | NOME | É_ALUNO | É_RESPONSAVEL 1 | ALUNO | TRUE | FALSE 2 | RESPON| FALSE | TRUE There is another table with the name responsavel_aluno , this table has t...
asked by 26.04.2018 / 03:28
4
answers

Help with distinct

I have the following sql query: select nome, data, situacao from cadastro The result is like this: MARIA 01/01/2018 0 MARIA 15/01/2018 1 GISELE 15/01/2018 0 CICERA 08/01/2018 1 ANTONIA 20/01/2018 0 ANTONIA 15/01/2018 1...
asked by 29.01.2018 / 14:12
2
answers

Perform multiple operations on a single SQL code

I have a table in MySQL as follows and structure: I would like to execute a SQL query that would do the following operations: Total number of records ( total1 ); Count how many records have id_nps_answer between 0 and 6 ( total2 )...
asked by 03.11.2018 / 16:40
2
answers

Display multiple records within a single MySQL [duplicate]

I have a question about assembling a select. I have 3 tables that relate M: N as follows: CurrentlyI'musingthissql:selectp.descricao,(selectdescricaofromitemwhereitem.codigo=c.codigoItem)asitemsfromprodutopinnerjoincomposicaoconc.codi...
asked by 04.01.2019 / 20:43
1
answer

How to query MYSQL in 2 columns and sort 1st results of column title and then column description

I am setting up a job agency website and I have a search that looks in the field title and description, what the person searched, as per the query below: SELECT * FROM vagas WHERE (titulo LIKE '%termo_de_busca%' OR observacoes LIKE '%termo_de_...
asked by 31.08.2018 / 14:33
3
answers

How to select the last lines added in a mysql table

I have the following table sir_ter_conversa which is a history of conversations. id|idterreno|idincorporadora|idusuario|msg|data 1 | 1 | 771 | 771 | a |2018-05-27 10:20:00 2 | 1 | 771 | 773 | b |2...
asked by 24.05.2018 / 19:24