Questions tagged as 'query'

1
answer

Working with group_concat

I have some questions regarding the use of group_concat , more specifically performance. When using group_concat you can not use limit . // a query retorna todos os ID's select group_concat( id ) from table limit 5 // pelo...
asked by 18.08.2015 / 00:53
1
answer

How to set up a query with optional conditions?

In the example: SELECT * FROM exemplo WHERE ID in(2, 3, 4) It does if you have these ID in the bank. PHP: $id= implode(', ', $_GET['id']); $nome= implode(', ', $_GET['nome']); $cidade= implode(', ', $_GET['cidade']); $q...
asked by 04.08.2015 / 17:51
1
answer

Incorrect usage of UNION and LIMIT

I want my query to return only the first record of the first table (if there is data in it), because the second table does not have repeated data. But it returns me this error:    Error Code: 1221. Incorrect usage of UNION and LIMIT My...
asked by 22.11.2018 / 15:50
2
answers

Bring all records if parameter is different

I have a contrato table with the concluido field of type tinyint(1) , if it is 0 it is not complete and if it is 1 it is complete. I'm going to pass this value by parameter to the query, how do I get all the data when the val...
asked by 07.12.2016 / 20:27
1
answer

SQL Query problems

I'm having problems with the following query: SELECT Cliente.Nome, (Reserva.NumeroNoites) TotalNoites From Reserva inner join Cliente on Reserva.ID_Cliente = Cliente.ID_Cliente group by Reserva.NumeroNoites, Cliente.Nome I would like to...
asked by 28.05.2018 / 11:39
3
answers

SQL Query export to excel

Good, I have some difficulties in the result of a query. For you to fit it is as follows, I have a registration application of "unavailable." and I need the following: Every day I have to extract a report from the previous day, however thi...
asked by 16.09.2014 / 14:56
2
answers

how to specify values to sort sql server

Good afternoon! Well, I have the following query below, however, I want to sort by specifying some records. Attached for example, is the generated query and I want the Value column to look like this: Diamond Gold Bronze Silver How do you s...
asked by 12.07.2017 / 19:21
1
answer

How to complement this sql query?

I have the following tables below, where schemas (columns) are described in parentheses and the primary key appears in bold: student ( codaluno , nombrealuno, dt_ingresso, codcurso) course ( coding , coursename) ( codaluno , codturma , ave...
asked by 30.09.2014 / 20:05
2
answers

How to update or insert MySQL in the same query?

In PostgreSQL, I have to use upsert . It checks if the line already exists, if it does, it does update, otherwise it does insert. In MySQL I am not able to do this, I saw some talking to use INSERT ... ON DUPLICATE KEY UPDATE , ho...
asked by 23.05.2017 / 05:42
1
answer

Query - Bring 5 higher records

I have the query below, where I need to bring only the 2 largest columns that have the highest values. Today is coming out like this: Conciliacao Extrato Integração 150 140 80 That is, I wanted to bri...
asked by 02.08.2017 / 23:50