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
-
1
votes0
answers30
viewsSearch range of numbers in Mysql
Good afternoon. In the customer’s ERP, in the footwear register the grid information is brought in string format, for example "27 to 40". This information goes to the site mysql via an automatic…
-
1
votes2
answers1323
viewsBring results equal to 0 as blank value in a query in SQL Server
I have a query below that the records that have nothing is coming with 0. I wish it could come blank. Example: select F.C37 [Pontuação], ISNULL(count(distinct TD.UsuIDCliente),'-') [Qtde_Clientes…
-
1
votes2
answers337
viewsAdd WITH query inside another query - SQL Server
Guys, how to add the query below as a subconsulta. Consultation with WITH: WITH dias AS( SELECT CAST('2017-06-26' AS DATE) AS dia UNION ALL SELECT DATEADD(DAY, 1, d.dia) FROM dias d WHERE d.dia <…
-
1
votes1
answer126
viewsInsert com select - oracle error ORA 00904
I’m having trouble understanding why this mistake. I want to insert a field {descricao_posto} on the table TB_POSTOS_NO_CONTRATO, using a select from another: TB_POSTO. A 1a. table has a fk_post…
-
1
votes2
answers1048
viewsBringing a sum in Sqlite Android
I have a problem in the development of an App, following, I have a list that all the data of donations in the bank, and in this Activity I created a Textview to receive the total value of those…
-
1
votes2
answers245
viewsorder by in oracle subquerys
RESOLVED I solved as follows, I created a view equal to my table of service orders more that was ordered by the team and by the priority, and then I kept the query above by only changing the table…
-
1
votes1
answer323
viewsQuery mysql_query does not return the column
Greetings to everyone in the community. I’m going through a strange problem. When I select query syntax and paste in Phpmyadmin, the query returns all the fields I want. But when I put it in the…
-
1
votes1
answer1316
views"Wildcard" character as a query criteria
I am trying to create a query criteria selection engine. For example: I have a mass of data where the following variables exist: store code Brazilian state in which it is located Brazilian region in…
-
1
votes1
answer50
viewsBind amounts in PHP and other languages
Safety and performance is extremely important for any application, so some techniques are used for development. One of them is the bind to perform any type of query in your database. When you do it…
-
1
votes1
answer27
viewsHow do I select between two dates and bring in the query the value 0 on the dates that do not exist?
Example select data, valor from tabela WHERE data BETWEEN '2020-01-01' AND '2020-01-10'. I need that when there is no day 5, for example, the query return me the 10 dates and on day 5 the value is…
-
1
votes2
answers1009
viewsRepeat previous rows when there is no record in SQL SERVER data
Friends, good afternoon! I came across a problem at work today, and I still haven’t found a solution to it. As I do not have much experience in the database area I am having difficulty to solve this…
-
1
votes1
answer74
viewsProcessing of graphical query via javascript
Good afternoon, I have a query in my system where it generates a chart. In the first chart caption is as Undefined, I was trying to redo my query only that it was not coming with the same values. I…
-
1
votes1
answer19
viewsError trying to use AVG in @query Spring
When trying to perform a query to return the average score with spring null error appears. When I test without avg(a.note) it returns the data correctly. @Query(value = "select new…
-
1
votes1
answer212
viewsT-SQL - Delete filter "NOT IN" does not work
I am filtering my base by store code (varchar), but the filter is not removing the store codes I want to delete from my query. This is my consultation: SELECT A.CPF , A.[Cod Loja] , B.NomeLoja ,…
-
1
votes2
answers151
viewsHow do I use two checkboxes in a C# mvc view to choose the query type?
Controller.cs public ActionResult pesquisarCliente(string _codigo) { var r = db.Pedido.AsQueryable(); if (!string.IsNullOrEmpty(_codigo)) { r = r.Where(n => n.Cliente.Contains(_codigo));…
-
1
votes1
answer926
viewsHow to make Inner Join in associative table?
Tables and Indexes: CREATE TABLE CLIENTE( IDCLIENTE INT PRIMARY KEY AUTO_INCREMENT, NOME VARCHAR(30) NOT NULL, SEXO ENUM('M','F') NOT NULL, ID_CARRO INT UNIQUE ); INSERT INTO CLIENTE VALUES…
-
1
votes3
answers1529
viewsEliminating duplicate values in SQL
I have a problem in a query, because there is only one field that differs from one data from another. I have tried using group by, order by, having, I searched in several forums, anyway, I tried…
-
1
votes1
answer532
viewsSeparate values from a multi select in columns
in my system, I have a multi select as they can come in the image below: And I export this variable in this select SELECT REPLACE(p.Argautor, ',', ';') AS Argautor FROM jud_Processos p LEFT JOIN…
-
1
votes1
answer68
viewsSQL Server Doubt 2012 - Query
I am having a hard time. In the consultation below, you are bringing in this way. Tarefa_Inclusao Tarefa 167909 167920 SELECT TarIDInclusao [Tarefa_Inclusao],tarid [Tarefa] FROM Tarefa WHERE TarID =…
-
1
votes1
answer35
viewsQuery to list the amount(Count) of records for a Foreign key
I’m trying to create a query that lists how many times a Foreign key has appeared from another table but I’m not getting it. I wanted to count how many times each customer appears in the order,…
-
1
votes1
answer19
viewsRelate Products to duplicated EANS in a relation where 1 product has n EANS. sql language
How could I make the comparison with the EAN of another product without comparing it to the same product... in sql? CREATE TABLE `produto`( `idproduto` INT NOT NULL AUTO_INCREMENT, `nome`…
-
1
votes0
answers51
viewsCustomer SELECT with payment for the last two months (60 days)
I have a TBCLIENTS table where I have the columns: NAME, DATA_PAGAMENTO, FORMA_PAGAMENTO. I need to know the customers who paid in the last 2 months (60 days) in the form of payment BOLETO. How I…
-
1
votes2
answers54
viewsTake only the first record of each condition
Good afternoon! I have the following table: How to get only the first record of each id_uni_sching? That is, I need to get the id_sching 534,382 and 524,075 (First time of each id_uni_sching) ?…
-
1
votes1
answer35
viewsSelect record that contains result equivalent to a variable
I have a column in my mysql table, in which it is called "positions", where several values in int are placed there, however, with the "|" of division. Example: 8|19|10|20| And each number represents…
-
1
votes1
answer156
viewsCompare group by sql server values
Something very unusual happened in my bank. Some records were entered more than once (7 to 13) to be exact. This occurred due to software error that has already been solved. Now I need to delete…
-
1
votes2
answers55
viewsMake an array for a query with false conditions
I have the following query, where the conditions are informed from a array: $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC',…
-
1
votes2
answers663
viewsHow can I differentiate a 'NULL' string from a null fact value?
I made this example for you to understand how the query is being made in the bank in my system. $sql = "SELECT * FROM tabela"; $result = $conn->query($sql); if ($result->num_rows > 0) {…
-
1
votes1
answer45
viewsquery in 2 tables at the same time
good evening, guys, need help in a query 2 tables if there is id in the second appears price if there is no price from the first table.. example Tabela1 table 2 ----------------…
queryasked 7 years ago sreletronica 21 -
1
votes0
answers820
viewsWhat is the significance of Overhead in physical database design?
I just read about physical design and database adjustment and could not understand the concept of overhead, and consequently could not understand what the author of the book wanted to explain. I…
-
1
votes1
answer515
viewsSelect com when e case
I have the following select query: select F.nu_ine INE, to_char(D.dt_ficha, 'YYYYMM') as CMP, I.co_cbo_2002 CBO, CASE WHEN (B.tp_atend = 1 or B.tp_atend = 2 or B.tp_atend = 5) and I.co_cbo_2002 !=…
-
1
votes1
answer103
viewsHow to do native query with paging?
I’m managing to make a simple select, but I don’t know the structure of how to make a select using Join. Follow the code below: That code works: @Query(value = "SELECT * FROM tabela1 /*#pageable*/",…
queryasked 7 years ago Leandro Jorge 79 -
1
votes2
answers97
viewsHow to use pseudo names with CONCAT and Mysql?
A question about Mysql asks the result to exit in this answer format. When finishing my solution through a consultation made on Mysql, find the following problem. Below is a first example solution…
-
1
votes1
answer212
viewsOptimize module 10 SQL Server
I have a database created by apróx. a decade, this same bank has several records and obviously, by being in production, can not be changed from day to night. The problem is: The products registered…
-
1
votes1
answer48
viewsAssigning values to a numeric array of values a PHP query
Given the table marcas of the database teste_db (for example) | id | marca | | 1 | mercedes| | 2 | audi | | 3 | fiat | | 4 | alfa | | ...| ... | |573 | ferrari | |574 | bentley | and given an array…
-
1
votes1
answer189
viewsExample Query Count
Would anyone have any example of how to make a COUNT in a query, separating the data by EstadoId (as an example). In my case I have several data in my database, registered by several states, I need…
-
1
votes1
answer1277
viewsError running Procedure on oracle
I got this trial: CREATE OR REPLACE PROCEDURE buscaturma(cod in INTEGER) AS nomeT varchar2(20); BEGIN dbms_output.put_line('inicio'); IF (cod=0)then dbms_output.put_line('ZERO'); ELSE SELECT…
-
1
votes1
answer100
viewsDoubt - Case when inside a Stuff - SQL Server 2012
Guys, how do I put a case when exists within the query below. The result is currently coming out like this: Customers Drugstore, Soccer, Gelagua However, I want to put a case when exists if it is in…
-
1
votes3
answers281
viewsLonger date search for a specific ID
I have a problem in a SQL where I need to find the biggest date of a ID specific, where it has several records of this same ID: Dice: ID - date - name 2 - 10/10/2004 - cesar 5 - 10/10/2008 - Japan 4…
-
1
votes1
answer4525
viewsHow to handle Null fields in Postgresql
Hello, I need to know how to best use COALESCE to treat the null fields in my table. My problem is the following, I’m simulating 6 Stores and their respective cards, let’s assume that one or more…
-
1
votes1
answer562
viewsSum Count() in mysql
I have this query that returns me the amount of equal dates: SELECT `Data`, COUNT(`Data`) AS 'Quantidade' FROM sua_tabela GROUP BY `Data`; | Data | | 2016-06-09 | | 2016-06-09 | | 2016-06-09 | |…
-
1
votes1
answer102
viewsHow to add methods to a Queryset?
I have a model defined in Django. I would like to add to this model a method that returns me part of a mounted query (a Queryset). That is, a method I want to define a method that affects the…
-
1
votes1
answer78
viewsQuery Doubt in SQL Server 2012
I need that in this query come only records where the ABC CURVE column is different from the MODEL column. For example, this customer the ABC curve of it is silver and the model is diamond/gold, so…
-
1
votes1
answer250
viewsQuery to return middle text from a field
I have an appointment that returns some class names/disciplines, but I wanted you to bring me only the names of disciplines. Below follows the query result with the default…
-
1
votes2
answers73
viewsHow to use forech in Wordpress using the Wp_query variable
Good morning! I’m not able to implement a forech in a database search using the native variables of wordpress, searching found something similar however is not what I need. <?php global $post;…
-
1
votes3
answers250
viewsDelete repeated records in PHP
Good morning, I’m here with a very big question. I’ve been at this all day and I haven’t been able to fix it yet. I have a database in sql server and I need to present some buttons with the records…
-
1
votes1
answer48
viewsHow to use NOT IN with data from another server in PHP
I set up a table with Data that nay should be sought, I’ll call you here Table. The data that was in this table are these: |Tabela_Not| Londres Tóquio Paris And I applied this Query to make the…
-
1
votes1
answer42
viewsRecording value of a variable in a table
I’m trying to save the data of 2 variables in a table, but when I look at the table in the database is recorded the values as 0. public void inserir(List<Conta>list) { List<Conta> lista…
-
1
votes0
answers351
viewsToo much delay in query only in Mysql
Here in the company we have PG and Mysql databases, these two banks are networked and are identical in both structure and data, where a "robot" mirrors them every 10 min. So far so good... It turns…
-
1
votes1
answer65
viewsmysql random questions
I have a somewhat complex question and I need help: I have a database with the following links: Exemplifying: I am in the history class about Karl Marx. This class is linked to a certain group of…
-
1
votes1
answer53
viewsBlank consultation
I’m starting in the world of programming and at first I have a problem when I run the query locally the query shows me the return normally but when I try to query through a simple application:…