Most voted "query" questions
Query or *query* refers to the act of recovering data previously stored in a computerised system from certain parameters and/or filters, by means of a specific command or operator.
Learn more…1,160 questions
Sort by count of
-
5
votes2
answers10554
viewsSelect with "different" expression with two conditions
I wonder if there’s any way to make a select using a where for a field with the parameter other than < >, where it has two or more items. To facilitate follow example: select * from…
-
5
votes2
answers15372
viewsConversion of an nvarchar data type into a datetime data type resulted in a value outside the range
Code line INSERT [dbo].[Shop_Goods] ([TemplateID], [Name], [Remark], [CategoryID], [Description], [Attack], [Defence], [Agility], [Luck], [Level], [Quality], [Pic], [MaxCount], [NeedSex],…
-
5
votes2
answers1012
viewsConsultation with Eloquent do Laravel
I have this consultation: select Q.id,Q.questao, D.disciplina, S.serie, S.ensino from questoes as Q left join capitulos_questoes as CQ on CQ.questoes_id = Q.id left join modulos_questoes as MQ on…
-
5
votes3
answers1003
viewsHow to make a select within a condition?
How can I create a script in SQL where a SELECT, and as the result of a column of this first, performs a certain condition of another table? example: select * from tabela as t SE t.saldo = 0 entao…
-
5
votes1
answer1044
viewsHow to bring only a certain part of a text in a field
How do I bring only a piece of text into a field in sql server? I have the query below that in the Description column, it returns a text with a lot of information as for example. Nome Cliente Data…
-
5
votes2
answers86
viewsHow does ORDER BY draw columns in case of a repeated value?
Suppose I make one SELECT sort of like this: SELECT * FROM "users" ORDER BY "createdAt"; In this context, if I have data that has the same value in the field createdAt, how SQL will sort these…
-
5
votes1
answer647
viewsHow to deal with multiple quotes in R?
My problem is using quotes in a query within a R function. I have to call a list of select * from probes."probes_90_2018-05" For that I do: coelho<-dbConnect("PostgreSQL", fnord)…
-
5
votes2
answers1131
viewsSQL QUERY using MAX function
I’m having a problem with a basic consultation of SQL, is for a migration of database. The query aims to bring data from the table of ASSOCIADOS/CLIENTES, but beyond this table I have another…
-
5
votes1
answer695
viewsSELECT within variable in PROCEDURE
I’m not getting the result of a select within a variable. I want to add the column turno inside my WHERE. The problem is I get the value of @turnos in the following 3 formats: 1 - 'A' 2 - 'A','B' 3…
-
4
votes2
answers6308
viewsOptimize Mysql tables
I work with some huge tables in a system I developed. These tables are constantly being updated and sometimes the query becomes slow. Some of them even have more than 100,000 lines. I would like to…
-
4
votes3
answers1778
viewsHow to select rows from table A that are referenced in a column of table B?
I am trying to execute a database query to collect all rows in table A referenced in a column of table B: Query I am running -- Consulta a recolher da tabela A as linhas com ID referenciado na…
-
4
votes1
answer359
views -
4
votes1
answer235
viewsGrab the latest message from a conversation (GROUP BY)
I have the following query: SELECT cp_mensagem.mensagem, cp_mensagem.dh_envio, cp_projeto.id as id_projeto, cp_projeto.nome as nome_projeto, cp_pessoa.id as id_freelancer, cp_pessoa.nome as…
-
4
votes1
answer1838
viewsHow to Use "Not Exists" in LINQ?
I am trying to translate the query below, in LINQ, but without success, someone can help me? SELECT * FROM PESSOAL A WHERE NOT EXISTS ( SELECT Chapa FROM PRODUCAO B WHERE B.Chapa = A.Chapa AND…
-
4
votes1
answer241
viewsInner Join between two tables
I tried it this way but it’s wrong SELECT * FROM produto INNER JOIN familiaproduto ON familiaproduto.idfamiliaproduto = produto.idNomeProduto INNER JOIN qualitygate ON (qualitygate.idQualityGate =…
-
4
votes1
answer589
viewsHow to capture a Mysql query from a given table in real time?
I am wanting to capture the queries that are sent to Mysql of a particular application, it is possible?
-
4
votes2
answers1384
viewsSort by day of the week starting by today
I want to sort the results by days of the week I have 7 events, 1 event for each day, and have to order in the following way: Sunday, Monday, Tuesday, fourth, Thursday, Friday, Saturday Assuming…
-
4
votes1
answer4598
viewsHow to list a sample of all tables in a Mysql database?
I need to sample all tables in a Mysql database, for example through a SELECT * ... LIMIT 10. I already have the code that returns all tables of the current database: select table_name from…
-
4
votes4
answers2981
viewsSQL Query Joining 5 tables
I need help to do a query (multiple relationships) on my Webservice + Mysql to return the result on my Android app. I have these respective tables: Query I need to query a person(tb_suspect), with…
-
4
votes1
answer824
viewsCreate Dto by Constructor with a List parameter of a Hibernate entity
I have a @Query Spring, which performs a database query by an Entity, to create some Objects DTO. And the properties of this DTO object, I pass via Constructor, but I needed to pass as parameter in…
-
4
votes1
answer415
viewsHow to send data from one table to another with the Deleted command
Guys I’m creating this trigger in the SQL Server, but I’m not getting the id to send the data to another table and delete from this table. CREATE TRIGGER MoveComprador ON comprador INSTEAD OF DELETE…
-
4
votes1
answer1056
viewsTracking and posting system (social network type)
I’m developing a new project and I’m creating a profile following system where the goal is to show only the publications of those I follow. Such as a social network. I follow the person, so I get…
-
4
votes1
answer94
views -
4
votes1
answer360
viewsDisplay Average in an SQL query
I want to conduct a search in a query So far I have only been able to display the total value of the records. the idea is to show the spending average. Then it would be the (total / quantity)…
-
4
votes1
answer256
viewsConvert LINQ to Dapper query
I have a LINQ query where I get the complete data. Because of performance, I am converting the query and using Dapper. I have the following entities: public class Cliente { public int ClienteId {…
-
4
votes2
answers1837
viewsGroup column sum by quarter
I would like to group the sum of one column per quarter, that is every three months. I have the following query which groups from month to month: select month(data) as mes, year(data) as ano,…
-
4
votes1
answer139
viewsRecover last row inserted in table with non-sequential primary key - Mysql
It is possible to know which was the last row inserted in a Mysql table where the primary key is not sequential? I have a table where the primary key consists of two columns that are FK, so they…
-
4
votes1
answer50
viewsHow to configure predicate to return only 2 columns?
Setting: Query using Coredata for records with a city and state, and return only the columns 'name' and 'address' of the location. I am currently using the following query: // Array that will be…
-
4
votes5
answers19374
viewsHow to check if a field of type text or ntext is null or empty?
How can I check whether a field of the type ntext is null or empty in where? I got the following select SELECT Subject, Notes from DocumentNotes where Notes is null or Notes = ' ' but when comparing…
-
4
votes1
answer539
viewsWhat’s the difference when you use Inary in the Where clause?
What is Binary and what he does? What is the difference generated when using the Binary in a query in the Mysql and when it does not use the Binary? SELECT email, senha from login WHERE usuario = ?…
-
4
votes1
answer339
viewsUse IN or multiple OR? Which one performs better?
I have the following queries in Mysql: 1º: Using multiple devices OR SELECT SUM(qtd) FROM produtos WHERE qtd > 10 and (status = '0' or status = '4' or status = '7') 2º: Using IN SELECT SUM(qtd)…
-
4
votes1
answer849
viewsListing the most offensive querys in Mysql
I would like to know which are the most offensive queries in my database. I have already used the conventional methods "Show full processlist" and among others.
-
4
votes2
answers6935
viewsConcatenate values from the same column
How to concatenate the values of the same table Table example | Usuario | Formulario | Acao | Permitir | | Admin | Contrato | Imprimir | 1 | | Admin | Contrato | Consultar | 1 | | Admin | Contrato |…
-
4
votes2
answers923
viewsIs it possible to use native query + spring date for paging?
I need to make a pagination using dynamic querys because I have to do many joins, I’m trying to make only one select * to test the use of native query + spring data, but the error message is as…
-
4
votes2
answers167
viewsTake mysql field dynamically
I created a select command based on information sent by the user, e.g.: $anoini = $_GET['anoini']; //variavel com ano escolhido pelo usuário $anofim = 2016; //ano final é 2016 $s = 'SELECT…
-
4
votes1
answer4332
viewsHow do JOIN in 4 tables or more?
I need to make a select on four tables but I’m having a headache with it, follows the image of how they are related: It would be something like : SELECT integrantes.id_integrante,…
-
4
votes1
answer46
viewsQUERY - Can anyone help me mount this query?
I have these 3 tables below: "users", "Friends" and "posts". I want to take all my friends who are in the table of Friends and display their posts, taking the name of each and their image (which are…
-
4
votes1
answer370
viewsUse of CONCAT, CONCAT_WS and GROUP_CONCAT
I’m building a query where I look for results within the concatenation and get enough to ask for help. I currently use Mysql with the PHP application. In the example below, I look for the words…
-
4
votes2
answers7919
viewsHow to join 2 select in mysql
I have 2 select which are basically identical, changing only 1 table. I’m trying to put the 2 together in a single select, but I’m not getting it. Follows the select: SELECT DISTINCT a.id,…
-
4
votes2
answers128
viewsQuery conditional ordering in Mysql
I have a table called comentarios, formed by the columns: id, descricao, criado_em and comentario_pai, how it is possible to see in the photo. I need to create a query, in which the answers are…
-
4
votes2
answers213
viewsHow to filter only the last day of each month?
How can I filter a query bringing the result by the last day of each month, in SQL Server 2012? I tried the EOMONTH, I think due to the version. SELECT E8_FILIAL, E8_AGENCIA, E8_CONTA, E8_DTSALAT,…
-
4
votes5
answers2275
viewsHow to reduce the search time in a table with more than 200,000 records?
I’m trying problems to list and search data table with more than 200 thousand records. I read in researches, that for the search system, the ideal would be to make indexes of type "fulltext" in the…
-
4
votes1
answer145
viewsTrigger without replicating data - SQL Server 2012
Guys, I have a Trigger in the FRM_46 table that would replicate the data right after the Insert or update to the FRM_31 table, however, it is not replicating, I already analyzed and made the tests,…
-
4
votes1
answer392
viewsRandomly select lines
I am developing a very complex system, where, in some cases I need to select only a few fields, a friend who has more experience in the area gave me some tips, but he did not explain why. I have the…
-
4
votes2
answers376
viewsSELECT displaying products except the results of another SELECT
I have this SELECT that picks up the 6 best selling products: SELECT IdProduto, SUM(QtdProdutoPedido) as QtdProdutoPedido FROM tb_pedidoproduto GROUP BY IdProduto ORDER BY QtdProdutoPedido DESC…
-
4
votes2
answers276
viewsUsing a select with UNION or other mysql parameter
I am developing cash flow from my company and am encountering a difficulty. I have two different tables. A table is a tb_compras(id, fornecedor, nfe, valor, data) and then I have another table…
-
3
votes4
answers3679
viewsConsume values from a webservice
I have no knowledge in the use of webservice, and I need to use one now to consume data from a database(Normally I would fetch the data directly from the database, but in this case the admin did not…
-
3
votes1
answer3217
viewsHow to prevent a simple query from traversing the entire Mysql database
I have an application in Rails that uses a Mysql database with a table with millions of rows. Sometimes it happens that some part of my application does a very heavy query, locking all the rest of…
-
3
votes1
answer8490
viewsOracle Relationship Search Query
I have a program to search dependencies of records to proceed with data deletion here in the company. We support some databases but on Oracle the query is processed very slowly (about 10 to 15…
-
3
votes2
answers101
viewsQuery of N records by Item
I have a history table on DB2 and would like to carry out a PLACA however despite this I would have to return the last 5 records of each PLACA. Ex.: |ID |PLACA | DATA | VALOR | |12 |ABC | 2014-08-28…