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
-
2
votes3
answers3588
viewsHow to store more than one value in an "SQL variable"?
I work with a system that has a very limited report. The reports are basically restricted to one sql query. I need to present in a report a query that, in my query, is being informed by the user a…
-
2
votes2
answers55
viewsWhy do if or case tests not work in this subquery?
I am trying to run the following subquery within a view: (SELECT if(idnotas > 0, "não", "sim") FROM notas WHERE vendas_idvendas = p.vendas_idvendas ORDER BY idnotas DESC LIMIT 1 ) as…
-
2
votes1
answer70
viewsList users' phones from a Join without duplicating lines
Good night, Guys, I have the following problem: I need to make a Join in two tables, USER and CONTACT. Each user has more than one contact (Phone), so when I list the data he returns me lines…
-
2
votes1
answer106
viewsHow to join these two querys in one?
I have a table that records user reviews in Forum responses in rating, where: 0 = Vote No; 1 = Positive vote; 3 = Vote Annulled If I want to take all votes in response from a single user on a topic…
-
2
votes1
answer122
viewsHow to check if there is a number in several fields of a table
I have a table in a Sqlserver database that simulates a bingo card. In total there are 25 fields that represent the card: n1, n2, n3, ..., n25 Let’s say I drew the numbers 5, 28 and 67, as I do a…
-
2
votes1
answer41
viewsA field in table 1 related to 2 fields in table 2
Let us suppose two tables Table 1 : emp (table of employees) Campos : emp.no (chave privaria), emp.name (chave múltipla, não primaria) Table 2: webConference Campos: webConferencia.no (chave…
-
2
votes3
answers133
viewsSUM of one table minus the SUM of another in the same field
Hello, I am self-taught and already do some consultations in SQL but "stuck" in this. I need a list where one of the fields should show the total of a column, minus the total of another that is in a…
-
2
votes0
answers83
viewsDatabase variables are not added in $_SESSION array
I am building a cart for an application. I want to add the name, quantity and price of the product inside the cart. For this, I do: In the header I include in the pages accessed by the client:…
-
2
votes2
answers191
viewsCOUNT() query does not work
The purpose of the query is to list, within a user-defined period, all states and their total number of independent quotes if zero. Customers must be active (status 30) and have city id number…
-
2
votes2
answers75
viewsLooking for a group of duplicate records
I have the table below: declare @order table (idOrder int, altcode varchar(17) ) insert into @order values (1,'11111111111') insert into @order values (1,'22222222222') insert into @order values…
-
2
votes1
answer208
viewsHow to Find Higher or Lower Values between Columns within a Data Frame in R
I have a data frame x, and in the column of the name V_de_Busca, where the value is greater than 0, I need to search the column V_Encontrado and locate the first value larger than the one searched…
-
2
votes2
answers127
viewsSearch last access record with MYSQL
Suppose I have the table clientes: -------------------------------------- | ID| Cliente | Data_Registro | |------------------------------------- | 7 | Joaquim | 2019-07-17 09:45:00 |…
-
2
votes1
answer473
viewsHow to count the number of empty columns in MYSQL
I have a MYSQL client registration database. I need to make a query to know the amount of blank columns each record has. For example, in total I have 15 columns (name, email, address, etc) and "So"…
-
2
votes1
answer58
viewsDoubt about SQL - Group by (beginner)
I have two tables, one with the names of doctors and the other with the classifications of the appointments and I want to list the doctors and the quantities of appointments based on the…
-
2
votes1
answer162
viewsSELECT Recursive (SQL)
Good afternoon! Guys I’m having the following difficulty: Imagine that I have a list of several Customers, and each customer has a Rating Group ( the Rating Group can be repeated for some…
-
2
votes2
answers109
viewsCONSULT DATA FROM A FOREIGN KEY TABLE
I have 3 tables in a database, one houses customer data, other products and one sales, containing foreign table id key products and customers. I need to make a query that shows the purchases made by…
-
2
votes0
answers27
viewsInterconnection of tables in Mysql in Java program
Good afternoon ladies and gentlemen, I am developing a project for study with 2 tables and these tables need to be connected in a certain value. In my package DAO, have 2 classes Stockpile and…
-
1
votes2
answers1120
viewsINNER JOIN does not return database result
I’m trying to use this code: SELECT * FROM tb_trabalhador INNER JOIN tb_detalhe_trabalhador ON Tb_trabalhador.id = tb_detalhe_trabalhador.tb_trabalhador_id And it returns the blank result. Is there…
-
1
votes2
answers946
viewsQuery the return of an Ajax
I have a field select and need to query and load the result dynamically with Ajax. I currently have the following code (which does not appear to work or to be incomplete): $('#formProd…
-
1
votes2
answers436
viewsQuery SQL condition if
I have a problem in doing a query where I have 3 fields and just one of them is filled that no longer shows this result. Someone can help me do that? select * from tabelas where campo1 and campo2…
-
1
votes1
answer347
viewsDirect sum by SQL query
I wonder if there is a way I can make a simple sum directly by the query, I have a table that contains a sub-table called VIEWS and I would like for each query that I run these VIEWS to increase +1…
-
1
votes6
answers708
viewsHow to count the number of clients that returned from one year to the next through SQL?
I have a table Serviços(Nro_Serv, Data, Cliente, Valor) 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…
-
1
votes1
answer1533
viewsList sub-query table with main query
SGDB: Mysql. PROBLEM: I need to somehow relate the subquery (being table and highlighted field Funcionario.codZona1) with the table "Zone", which is in the main query. Is there any way? Table…
-
1
votes1
answer2650
viewsUpdate with Inner query by selecting the same table
I have the following query: UPDATE cp_feedback_trabalho as a SET a.visivel = 1 WHERE a.dhEnvio IS NOT NULL AND EXISTS ( SELECT b.id FROM cp_feedback_trabalho as b WHERE b.id_pessoa_que_enviou =…
-
1
votes1
answer845
viewsSelect in SQL Server with Intel
I wonder if it is possible to select in Sql Server a table that does not have an index column, but in this select display a sequential index column in ascending order. Ex. Table: Lettering Coluna D…
-
1
votes2
answers333
viewsQuery using Mongoose in Nodejs always returns null even within asynchronous method
I am trying to recover a document in my Database using Mongoose in Node.js but it always returns Null. My problem before was the asynchronous method, but now everything is running within it. And I’m…
-
1
votes2
answers112
viewsStrange code (Green) coming back from the database
I have the following PHP query $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE); $mysqli-> set_charset("utf8"); $stmt = $mysqli->prepare("select header, title, footer, head from configs");…
-
1
votes2
answers685
viewsHow many lines did a database query return (Cake PHP)?
$this->Post->Comment->find ('all', array('conditions' => array('Comment.post_id' => $id))); I do this query, how to know if returned 5, 7, 10... comments before displaying them in the…
-
1
votes2
answers623
views -
1
votes3
answers353
viewsHow can I split this INSERT into steps?
I have 70MIL records to insert into one Tabela3 from Tabela1 - 4 fields and table 2 - 1 field. The following code does exactly what I need the most optimized way a user has helped me build. INSERT…
-
1
votes2
answers815
viewsCan a worse cost query be a better performance query?
Context Here at the company we have a very complex query that encompasses several business rules, for presentation in a Workflow and for now I am evaluating it on Sqlserver. The performance of this…
-
1
votes1
answer4703
viewsConversion is not valid
public int ObterTotalAcessos() { int obtertotal = 0; using (var connection = ServiceLocator.ObterConexao()) { var command = connection.CreateCommand(); command.CommandText = "SELECT SUM (ACESSOS)…
-
1
votes1
answer205
viewsTransform javax.persistence.Query to Arraylist
It is possible to transform a javax.persistence.Query in ArrayList. I need to return an object of the type Query but it cannot have all the values of the result. I want to eliminate some results…
-
1
votes1
answer138
viewsQUERY SELECT (oracle sqldeveloper)
Have the query below. SELECT 'A. ABERTOS' QUANTIDADE, (SELECT SUM(S) FROM (SELECT COUNT(*) S FROM VW_SOLICITACAO_DETALHE VW INNER JOIN SOLICITACAO SOL ON SOL.ID_SOLICITACAO = VW.ID_SOLICITACAO WHERE…
-
1
votes3
answers98
viewsHow to consult and return all product information?
I have the following problem and I will ask a question in a didactic way so that it can be useful to all users who may need it. I want to conduct a consultation SQL that meets all requirements and…
-
1
votes1
answer1837
viewsSelect Rows in a Postgresql array
I am using the Postgresql and Python database to query it, I have the following modeling: I’m trying to make an appointment that will return all the OrderItems of a Order in a array, for that I made…
-
1
votes1
answer96
viewsSql query return the same name with different date
My table Acidente is more or less like this: Vitima - DataRegistro Pedro - 10/02/2015 Pedro - 20/03/2015 Maria - 01/05/2015 Maria - 01/05/2015 I need to make a query (Sql) that returns the records…
-
1
votes0
answers56
viewsPerform a Query String
Staff have the following method and Query: mt_dispositivo = MtDispositivo .where("id_conta = 28 or id_conta = 29 or id_conta = 30 or id_conta = 36") .select('nome, data_criacao, data_atualizacao,…
-
1
votes1
answer84
viewsProblem with LEFT Joins joins and one condition
I have had this problem for some time. I count on your help. I have 3 tables: publicacao id cartaz titulo 1 eradogelo.jpg A Era do gelo 2 ojogo.jpg O Jogo 3 helpme.jpg Help Me 4 please.jpg Please 5…
-
1
votes2
answers147
viewsUpdate running multiple times in a single instance
I have had a problem in my system that some pages that do UPDATE in stock tables sometimes run multiple times, so the page was not loaded twice because I created a protection account this. A single…
-
1
votes2
answers437
viewsSorting in recursive query
In another question I asked i had found a solution but ordering only works if the ID’s are growing: USE TESTE GO WITH Niveis AS ( -- Membro âncora SELECT Id, IdPai, convert(varchar(1000), Nome) as…
-
1
votes1
answer630
viewsInner Join, multiple Inserts with multiple conditions
Well, the thing is, I don’t understand where I should start, if I should select customers first, anyway, I’m sure I’ll use inner join or some joiner because it uses other help tables. I wanted help…
-
1
votes1
answer962
viewsQuery SQL returning duplicate records
I have two tables (adwords_performance and analytics_transaction) and I need to make a SELECT adding up the columns adwords_performance.clicks, adwords_performance.impressions and…
-
1
votes1
answer67
viewsProblem with product update
In the query the goal is to update the unit of the product, with a subquery which retrieves the current unit from the bank and subtracts by checking by code. UPDATE loja.produto SET UNIDADE =…
-
1
votes1
answer177
views -
1
votes2
answers198
viewsHow to mount PDO query with items previously concatenated
The doubt is the following, in mysql we can concatenate a query and then perform the search, as follows: $cidades = '&& (cidade = 100 || cidade = 101 || cidade = 102)'; $order = 'id ASC';…
-
1
votes2
answers1247
viewsProblem inserting double value in Mysql
query += txtServidor.Text + "',";<br> query += double.Parse(txtVencimento.Text) + ",";<br> query += int.Parse(txtBanco.Text) + ",'";<br> INSERT INTO tbl_associados…
-
1
votes0
answers350
viewsHow to plot multivariate functions with multiple constraints in the 3D plane with Wolfram Alpha?
I’m doing Calculus II at UFRN and I’m having a hard time analyzing certain forms on the 3D plane, so I decided to use Wolfram and its API to help me with my studies. This is a problem of an exercise…
-
1
votes1
answer804
viewscheck the time periods available in the SQL table
I am developing a schedule for a software that manages schedules available for scheduling, it seems strange that I post this here more by incredible that it seems not found anything of the kind here…
-
1
votes1
answer77
viewsPHP MS Sql query script for My Sql
Good afternoon. How can I make a query in MS Sql and insert the values in a My Sql table through PHP? Looking at this data, you can do this insertion? #--> conexao mysql…