Questions tagged as 'query'

3
answers

Why does GROUP BY not work with MySQL in this case?

I'm using the MySQL language and am trying to group a profession table with GROUP BY through the query below. SELECT name, occupation FROM OCCUPATIONS GROUP BY occupation; But I get this error when trying to group the professions....
asked by 02.12.2017 / 19:37
4
answers

SQL Query Joining 5 tables

I need help to make a query (multiple relationships) in my WebService + MySQL to return the result in my Android application. I have these tables: QueryIneedtoqueryaperson(tb_suspeito),withtheattributes(Name,cpfandRg).PreparedStatementstat...
asked by 30.10.2014 / 13:23
1
answer

Inner join between two tables

I tried it like this but it's wrong SELECT * FROM produto INNER JOIN familiaproduto ON familiaproduto.idfamiliaproduto = produto.idNomeProduto INNER JOIN qualitygate ON (qualitygate.idQualityGate = produto.idQualityGate1 and qualitygate...
asked by 13.10.2014 / 14:59
4
answers

Get the highest value by category by also loading the ID

The table is in the format below ID | CATEGORIA | QUANTIDADE 1 | A | 23 2 | A | 12 3 | A | 11 1 | B | 15 2 | B | 10 I want a query to return the following table ID | CATEGORIA | QUANTIDAD...
asked by 21.10.2015 / 23:10
1
answer

Search all websites

It is very common to find a search on sites that returns records from different tables. I need to implement a search on my site that returns produtos and usuários (profile) registered on the site. The result should be mix, but t...
asked by 28.07.2015 / 17:28
1
answer

How to do JOIN in 4 tables or more?

I need to do a select in four tables but I'm having a headache with this, follow the image of how they're related: It would be something like: SELECT integrantes.id_integrante, integrantes_documento.nome_integrante, integra...
asked by 15.12.2017 / 14:30
2
answers

SELECT displaying products except the results of another SELECT

I have this SELECT that takes the 6 best selling products: SELECT IdProduto, SUM(QtdProdutoPedido) as QtdProdutoPedido FROM tb_pedidoproduto GROUP BY IdProduto ORDER BY QtdProdutoPedido DESC LIMIT 6 I wanted a SELECT to show...
asked by 15.12.2017 / 19:56
1
answer

What's the difference when using binary in the where clause?

What is Binary and what does it do? What is the difference generated when using Binary in a query in MySQL and when not using Binary ? SELECT email, senha from login WHERE usuario = ? && senha = ? SELECT email,...
asked by 19.05.2017 / 15:26
1
answer

Use IN or multiple ORs? Which one has the best performance?

I have the following queries in MySQL: 1st: Using multiple OR SELECT SUM(qtd) FROM produtos WHERE qtd > 10 and (status = '0' or status = '4' or status = '7') 2nd: Using IN SELECT SU...
asked by 06.07.2017 / 15:45
3
answers

How to select rows from table A that are referenced in a column of table B?

I'm trying to run a query on the database to collect all rows from table A that are referenced in a column in table B: Query I'm Running -- Consulta a recolher da tabela A as linhas com ID referenciado na tabela B SELECT A.* FROM table_esho...
asked by 24.12.2013 / 20:38