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
votes1
answer69
viewsIs it possible to optimize my code for a single query?
I have the following problem: I’m assembling a Highcharts chart with queries php and I end up having a while inside another because the result of the date I put in the next query, has to return in a…
-
1
votes1
answer110
viewsQuery with 3 conditions AND does not work the last condition
I would like to make a query in two tables that takes into account 3 criteria, but is not presenting the expected result. Select viaturas.vtr_numero From viaturas, despacho_ocorrencias Where…
-
1
votes1
answer74
viewsQuery to not repeat an already registered value
I have the following situation: I need to make an SQL query in a field to return only the vehicles that are registered in a form (table vehicles) and that the form despachos_ocorrencias the vehicles…
-
1
votes1
answer40
viewsReuse of Clause AND (ORACLE)
Eai Galera. I need to run a select where it gets very repetitive my conditions being various joins in the same table, Follows: select elfo.el_field_option_id "Centro de Custo ID", elfo.label "Centro…
-
1
votes2
answers72
viewsCount values in multiple related tables
I have 4 tables tbl_Distrito, tbl_Unidade, tbl_Servidor, tbl_Processo. tbl_Distrito: Cod_Distrito, Nome_Distrito tbl_Unidade: Cod_Unidade, Nome_Unidade, Cod_Distrito tbl_Servidor: Cod_Unidade…
-
1
votes1
answer260
viewsList Python-flask logged-in user post
I’m a beginner in flask and I’m doing an Appweb where the user can register and register and post, is a Virtual Arline system. I built the user with SESSION and can display only his data. In my…
-
1
votes0
answers98
viewsHow to reduce Mysql query execution time?
In a Mysql database 5.6 I have two tables, TAB_A and TAB_B, whose relation is from 1 registry in TAB_A to "n" records in TAB_B. I am making an appointment as indicated below. When the TAB_A table…
-
1
votes1
answer491
viewsMysql query using INNER JOIN with HAVING
I have two tables in Mysql. The first table curriculo has as ID cur_codigo. The second table envio possesses env_codigo as ID and env_curriculo as a foreign key to cur_codigo. The table envios…
-
1
votes1
answer101
viewsBirth date validation with LINQ
I am doubtful to conduct a consultation. I need to list in this query only the offers that are within the age group listed in view in the fields IDADEMINIMA and IDADEMAXIMA passing only the…
-
1
votes3
answers99
viewsSum of groups in an SQL
I need to do the TOTAL sum per office of a field of hours that is in decimal format, in addition, perform the conversion of it. I can do the sum of the employees, but I can’t add up to "groups" of…
-
1
votes1
answer625
viewsHow to use CASE in a Where clause
Hello, I have the following script situation: SELECT * FROM Formulario WHERE DataInclusao = '2019-10-28 08:19:54.000' AND chave = 'XXXXXXX' AND Id = 2 This table has a column called Productoid, in…
-
1
votes1
answer139
viewsHow to take the record value according to its position number in SQL SERVER
I’m randomly populating the tables of a database I created and I’m trying to populate a table that has foreign keys. My idea is to create a while loop and get the ID (the values are random) of the…
-
1
votes1
answer41
viewsReturn cluster in Mysql vector
I am trying to assemble a Mysql query with multiple joins, in this query has a column that may or may not come duplicated, I would like to put the duplicated rows by this column in an array, using…
-
1
votes1
answer51
viewsQuery problem to filter different fields in the same SQL table
I have a table with GSUITE usage logs and I would like to filter some metrics one of them is the one that follows and that I am having problems to accomplish. (I’m a beginner in SQL) I am looking…
-
1
votes1
answer325
viewsRemove space from a php string
I have a problem with an appointment SQL on the basis of a array. I am concatenating the values received from a text-area, by sql with a IN, follows sql example: select * from jupiter where imei in…
-
1
votes1
answer211
viewsTwo conditions in Where do not bring a result
I am doing a query in Oracle Database 12C and I have a problem: I want only products that have address_1 as 'A' appear in my ResultSelect. In the example below the item "code: 312107" it has two…
-
1
votes2
answers59
viewsAverage between select results
I need to calculate the average repair time for each application. Knowing that I have in hand the repair code, application code and time for each repair, what would be the best way to perform this…
-
1
votes0
answers50
viewsShould I avoid Queries?
Example scenario I have 3 tables: relatorios, atividades and carros. Table relatorios, will be the "cover" of the day, with date, initial and final mileage, etc. Table atividades, will be each…
-
1
votes1
answer29
viewsQuery optimization
Hey there, guys! I have this query (Mysql) to count amount of visits on a Mê in a given period, however it takes more than 1 minute to run. How can I optimize it? Thanks in advance. SELECT…
-
1
votes1
answer263
viewsHow to Query between two php+mysql Dates?
I can make the query between two dates. However, the query returns dates beyond those that were searched. Example: Consultation between 01-02-2000 and 02-02-2000 Below is my code: <?php…
-
1
votes1
answer229
viewsSELECT with two Foreign key, return the two tables even looking for only one of the keys
I have a table that has two FK to reference the same table. By selecting all elements that have one of the two FK, using the query: SELECT "Proposta".id, "Proposta".id_segurado,…
-
1
votes2
answers106
viewsSQL search between two tables with duplicate result
I have a View and a table. A View V_CUSTOMER with customer data, but does not have the same CPF/CNPJ as in the view, which is identified by the field V_CUSTOMER.CUSTOMER_ID that makes the…
-
1
votes2
answers120
viewsMysql - Select - how to group two different values into a single value
I would like help on a subject. I have a query that lists requests(orders), and each request has its status, for example: 'confirmed', 'refused' and 'unmarked', I would like to create a Select that…
-
1
votes0
answers46
viewsReduce and simplify redundant sql (mysql) query for financial reporting (account hierarchy)
I have basic knowledge of database and Mysql, I wonder if someone could help me decrease the 'size' of a query and its redundancy (facilitating future maintenance). This is a financial report with a…
-
1
votes1
answer32
viewsGroup mysql results
Good evening, I need to make a query in the table below: But bring me the result of how many type = E , type = S grouped by month, this result I will play in a chart that will display by month how…
-
1
votes2
answers147
viewsquery in PHP is empty but in SQL Server it works
Good afternoon, I have a procedure to run on sql server, if I run directly on SQL it runs normally, returning me the expected line as in the image below: but when I run codeIgniter 3 (php) it…
-
1
votes1
answer69
viewsHow to treat a field in SQL SERVER
I have two tables in SQL one of EMPLOYEE and another of Dependents and I need to bring the name of all employees, regardless of whether or not they have dependents and for those who have, I need to…
-
1
votes1
answer63
viewsSQL doubt in query
Can someone give me some guidance in this consultation? How to find out how many possible shows watched? For viewers of the day "24/07/2020" who passed the turnstile before the opening time of the…
-
1
votes0
answers32
viewsAdd a line in a Datagridview with a QUERY as Datasource
First I created a DGV and configured it the way I need, put the column names and formatted column by column the way I need, adding the default value for null, text formatting, type of input, etc..…
-
1
votes0
answers43
viewsSelect data in three Mysql tables and bring the latest result with the sum
I am trying to join data from three tables using this sql: select c.NOME,c.CPF,e.DATA_CAD ,e.ENFERECO as ENDEREÇO_Atual , sum(f.VALOR) from cli1 as c inner join end1 as e on c.IDCLI1 = e.ID_END…
-
1
votes1
answer58
viewsHow to count the amount of distinct occurrences in a BD and return
I have 3 tables in a library database. One is the member table, with the age of that member and one PRIMARY KEY. The second table, book, has a PRIMARY KEY isbn and the rest of the attributes authors…
-
1
votes0
answers34
viewsDoubt with JOINS and GROUP BY in an SQL (Access) query
Thanks for your help. I am not very advanced in SQL and I am facing a difficulty here, is the following: SELECT tbl_afs_pregao.numaf, tbl_items_pregao.nomeitem, Sum(tbl_items_af.qtd) AS SomaDeQtd,…
-
0
votes2
answers1051
viewsSQL QUERY get Average one month of a relative day of the week
I need a query that returns me to the average of a relative month, and a day of the week. For example: I need to know the components relating to the month of February, the day of the week Monday. It…
-
0
votes1
answer98
viewsHow to take the content of the JOIN clause condition
I have the following situation that can be seen in this link. The expression is: /((^|\s)(right|inner|left)\sjoin\s(.*?)on\s(.*?)(?=(inner|right|where)?))+/gmi I need to get the conditions inside…
-
0
votes2
answers159
viewsRegex in Mysql to fetch certain X tempo results
I have a field in the table defined as DATE and the data is saved in this field as follows: year-month-day hour:minute:second Exemplo: 2014/04/22 18:32:00 I need to develop a query that returns me…
-
0
votes1
answer351
viewsChange language in the database during a query
Is it possible to change the language of the database only during the execution of an insertion query? I am having problems with date conversion due to the formation of them, the Bank expects…
-
0
votes3
answers2325
viewsOrder By - Leave specific record for first
Store_Name | Sales | Date America | 1500 | 05-Jan-1999 Boston | 700 | 08-Jan-1999 Canada | 300 | 08-Jan-1999 Dinamarca | 250 | 07-Jan-1999 I have this table, I’d like to sort in a way where Boston…
-
0
votes1
answer5030
viewsJava check, show values recorded in Mysql database
I need help I’m making a game in java and I need all records and files and player etc in my table but I can not connect with the database and much less check and display values Ps: sun.java tutorial…
-
0
votes0
answers62
viewsDetecting Slow Queries in Rackspace’s Mysql
There is an easy way to see the slow queries in Mysql from Rackspace? I tried to those instructions, but they’re very complicated... Original post in English…
-
0
votes1
answer318
viewsSQL history query
I am in need of a help with SQL. I need to do a query that returns a history of the current date up to 7 days behind. Could someone please help me?
-
0
votes1
answer329
viewsWhat are the differences between sql commands?
What’s the difference, when I should use the following sql commands and which expressions can follow these commands? order by ,group by, join e union What is it for and when to use the commands…
-
0
votes2
answers96
viewsUndefined is not a Function in Node.js using Mongoose
I know that this mistake may have several causes, but I have not been able to know mine. I have a function to save a Document in my Mongodb and I am using callback for this. The code is executed…
-
0
votes2
answers89
viewsHow to order Contacts by name?
I have the following code and would like to make an ORDER BY name: try { String clsSimPhonename = null; String clsSimphoneNo = null; Uri simUri = Uri.parse("content://icc/adn"); Cursor cursorSim =…
-
0
votes1
answer113
viewsHow do you request Core Data to get only one attribute?
I just need to get an attribute from a single row of the table: name | id | idade | aprov|repro| sala | _______|______|________|______|_____|______| John | 32 | 15 | A | | 155 | Following the table…
-
0
votes1
answer200
viewspick number of results of a query with the database using cakephp
I want to make a loop to show the results of a database query, and get the number of results found in the query. I’m using the cakephp. Does it have any function that does the same thing as the…
-
0
votes2
answers4604
viewsHow to insert by selecting from two different tables?
TABELA 1 - ID - IMOVEL - CODIGO - IMAGEM_G <----- nessa tabela este dado é vazio. - IMAGEM_P TABELA 2 - ID - IMOVEL <----- nessa tabela este dado é vazio. - CODIGO <----- nessa tabela este…
-
0
votes1
answer110
views"Escape" file string externally loaded
Problem: I am trying to pass to the database a String containing the bytes of an image that was externally loaded to place in a BLOB field. As always, the bytes of the image have single quotes ',…
-
0
votes2
answers336
viewsI’m having difficulty returning my ID using nextval, to later do the Insert in my table
I’m having difficulty returning my ID using nextval, to later do the Insert in my table OleDbConnection cnx = new OleDbConnection(new AdministradorDAO().conexao); cnx.Open(); string seq = ("select…
-
0
votes1
answer336
viewsReturn last entry of each object in the database
I have two tables: monitor_carro id serial | setor_id | modelo | ano | placa monitor_evento id serial | lat | long | data | fkfuncionario_id | time | carro The monitor_event table has only one…
-
0
votes1
answer178
viewsProcessing of returned values in the query
I need to "handle" the return of a SELECT as follows: - value saved to the bank: www.dominio.com.br or www.dominio.com - value treated on page: dominio; I mean, I need query "remove" what is before…