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
answer162
viewsFilter JSON records by Javascript or PHP
I have a question about how to filter data when the customer fills in an input field. I am searching all server records (running PHP) through a jQuery JSON request and would like to know how to make…
-
1
votes3
answers963
viewsstore the value of a query in a php variable
I want to save the value of a select to a php variable, and then show it in html. I tried something like: function totalEspumas(){ $banco = abrirBanco(); $quantidade_pedidos = "SELECT…
-
1
votes1
answer1719
viewsHow to sort varchar field with letters and numbers in sql server
I have the following query below and would like to sort according to the image, however the numbers. WITH cteNiveis(IdConta, NivelRec, NomeTab, Caminho, Nivel, Tipo, Status, Nome) AS ( SELECT CO.Id,…
-
1
votes2
answers128
viewsHow to separate records into blocks for parallel processing?
I have a table in SQL Server that makes the control of messages to be sent and a routine in C#, configured in a Cron, which selects pending messages, sends and marks as sent. What I’m implementing…
-
1
votes1
answer541
viewsIs there a way to change the field type of a query in Delphi without having to exclude and include?
I have the following situation, I use Postgresql and Zeos in Delphixe, I needed to update the component to better support LATIN1 x UTF-8, now I can work with every type of character, blz. But…
-
1
votes2
answers201
viewsConvert from varchar to float when the string is empty and/or blank
I have a column where the strings are in the following format: "12.05%" I need to do some calculations with these values, and I am formatting the values that are acceptable for the float/double…
-
1
votes0
answers239
viewsHibernate Query with setParameters
Hibernate is ignoring my data from a Map when it is void. If I’m with setParameter("nome",valor) and the value is null it works, does anyone know how to solve? Follow the code: public List…
-
1
votes1
answer480
viewsSubquery returns more than one value
When performing an update within a precedent, the message appears saying that the comparison subquery brings more than one result. The subquery has been tested and brings only one result, since it…
-
1
votes2
answers126
viewsI want to search by name of any function from a search field
Guys... how can I make a system in which the input text gets a name from function.. then he searches his name internally with the name that is on string. guy... In HTML I do the following: <input…
-
1
votes2
answers494
viewsSQL Left Join - shorter date longer than current date
3 tables: Processo, Evento, Alerta The goal is to make a query that returns all processes by adding the columns of the most recent event type and date MAX(DataEvento) and the next warning (shorter…
-
1
votes1
answer113
views -
1
votes1
answer207
viewsAdd fields in a select
As that puts the idautor and idobra in this my SELECT: CREATE TABLE Obra_Assunto ( idassunto INTEGER NOT NULL, idobra INTEGER NOT NULL, PRIMARY KEY (idassunto, idobra), FOREIGN KEY…
-
1
votes2
answers301
viewsBring the records from one table according to the Where from another
I am new in the database area and I came across a situation that I do not know how to solve. Even though it seems (at least, rs) simple. Exists the table called dbo.FISICA and another call…
-
1
votes1
answer641
views -
1
votes2
answers565
viewsAdd multiple products to a single mysql order
Good afternoon I have two tables encomenda and prod_encomenda. My goal is to assign to one order several products. Both contain the id_encomenda, so I guess the structure of the tables is well done!…
-
1
votes2
answers56
viewsRails - query for non-connecting records
I have a Rails application and am creating a notification system, the problem is that I do not know how to query by notifications not viewed by a user in a practical way. The scheme of the…
-
1
votes1
answer333
viewsHow to duplicate a key’s value in SQL?
I need the keys Process and Numero_revisao, can receive values that already exist in the table. for example: Id = 1, Numero_Processo = 1, Numero_Revisao = 1 Id = 2, Numero_Processo = 1,…
-
1
votes3
answers255
viewsCalculate percentage between two MYSQL dates
Good morning! I wanted to calculate the percentage of how many times a classification appears between two dates, the classifications are distributed in "red", "yellow" and "green". This is the table…
-
1
votes1
answer309
viewsConcatenate lines with the same code
When executing the query select * from ivr_interacao,ivr_business where ivr_interacao.codigo = ivr_business.idvisita and ivr_business.campanha = 5 order by start_time asc I have the following…
-
1
votes1
answer65
viewsHow to perform 1 position offset SQL query?
I’m trying to perform a query where in one of the columns (COTA_DIA_ANTERIOR) return me the value of the previous day. But it is bringing the value of the day. SELECT ET.DT_REFERENCIA ,ET.VL_PU…
-
1
votes1
answer879
viewsVBA Excel - Index Match with two conditions
I have a spreadsheet with several tabs. In the first tab I have the following table: In tab 2 type the client and the type, and I wish to return the ID. For this I am using the following code in…
-
1
votes1
answer1842
viewsInsert quote text in mysql database
I am using the following code to insert a quoted text into a mysql database: mysqli_query($con, "insert into medicacaohistorico (data, unidadeori, unidadedes, itemdetalhe, qtd, solicitante,…
-
1
votes1
answer1153
viewsOracle SQL Query - Subtract Hours
Hello, I’m a beginner in SQL, and I’m in mortal doubt. This query is to analyze an execution log on a basis of my company. The problem is that the time zone of the OS is +0.00 which creates…
-
1
votes1
answer82
viewsHow to control filters for a query that persists in mongodb
I have this query in my api: @Query("{$and: [" + "{'online': ?5}, " + "{'locations.appointmentTimeRanges.weekday': ?6}, " + "{'specialties.name': ?7}, " + "{'healthInsurances.name' : ?8}" + "]}") I…
-
1
votes3
answers1210
viewsSelect to bring the amount of certain records in related tables
Speak guys, is the following, in the MYSQL database I have these 3 tables: CONTROLS: Here I do the training entries performed. Note that it is possible to insert several employees in the same line…
-
1
votes2
answers48
viewsApply condition depending on value
In the script below, I need to use a condition only if the field is filled (line is commented in script below). If not, this condition should not be part of the query. Is there any way to do this…
-
1
votes1
answer290
viewsSQL Query to Group Records in MS-ACCESS
Hello, I would like an SQL command for a query in a Access. The structure of the table is: tbList Id | Nome | Genero | Endereco | Estado | ... The result I would like to group by state and count the…
-
1
votes1
answer220
viewsINSERT WITH TWO TABLES - PHP
I have the table students and the table payments, I am doing a gym system. I linked the two tables by placing the id_students in the payments table as foreign key. I want when registering student…
-
1
votes1
answer133
viewsClause Where takes too long
I’m wearing the Laravel 5.6 My model is normal <?php namespace App; use Illuminate\Database\Eloquent\Model; class MyTable extends Model { protected $table = 'myTable'; public $timestamps = false;…
-
1
votes3
answers83
viewsHow to consult register that does not contain a certain code?
I need to make an appointment to list calls that haven’t been validated. It works that way: A call is a support request, in which several actions occur, and all are recorded in an auxiliary table. I…
-
1
votes1
answer240
viewsQuery joining two tables and filling in fields conditionally
I’m a beginner in SQL and I was wondering if you could help me with a question. I have two tables, one is called Cadastro_func and the other Cadastre. The 'Func_register' has the columns: 'Nickname'…
-
1
votes1
answer179
viewsAdding +x to each record returned in a SELECT
For example, in a select in the bank, will be returned 5 records: SELECT * FROM esc_usuarios WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "' AND usu_situacao = 'ativo'" Then I want to…
-
1
votes3
answers132
viewsError concatenating component value in query
As darlings in my C# Winforms project are being carried out through StringBuilder. It was suggested here in the O.R. query of Consulta.Append("Select * from...") for @"select * from..." for being…
-
1
votes1
answer90
views -
1
votes2
answers43
viewsObject attributes coming null in Query
Would anyone like to tell me why in my query, the attributes of the COR object, are coming null? I make that same appointment for Sizes, and you bring me the result waiting. however, when making the…
-
1
votes1
answer37
viewsQuery returns another user’s value
I am not able to compare the code (from the logged in professional) with the hired code (which should be the same as the logged professional) in sql query and this makes the query return a value of…
-
1
votes1
answer25
viewserror in wordpress query
I have the following appointment : <?php $footerlocal = array( 'numberposts' => 2, 'post_type' => 'page', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'zona', 'value'…
-
1
votes1
answer73
viewsReceiving and handling data from a query
I would like to know how to manipulate the data of a query. I have a method that performs a Select, and I’m creating a List to store the results, and return this list. But how can I use this data…
-
1
votes1
answer38
viewsRepeat query there is database using for in PHP
I have the following appointment $turmas= $wpdb->get_results( $wpdb->prepare( "SELECT nome FROM turmas WHERE id= '%d' ", $_POST['idSerie']), ARRAY_A ); When I get $_POST['idSerie'] with an…
-
1
votes1
answer106
viewsCount repetition amount of an item
I have a table where were inserted several repeated items, I need to return all these items that have more than one register. So I made the following query: SELECT COUNT(ID), CODIGO, DESCRICAO,…
-
1
votes1
answer283
viewsHow to add values after filtered in Django?
Here’s my loop (in my.html template): {% for item in filter.qs %} <tr> <th scope="row">{{ item.id }}</th> <td>{{ item.nome }}</td> <td>{{ item.data|date:"d, F"…
-
1
votes1
answer1695
viewsSQL how to select in 2 different columns
I’m trying to make a SELECT to select 2 different columns from the same table, example: id | name | tags ----------------------------------- 1 | acao | null 2 | aventura | null 3 | rpg |…
-
1
votes2
answers580
viewsLaravel - Select in multiple tables
My goal in the code is: - Create a filter option for the customer, where he will have the options to filter the product by: COLOR, GROUP, FEATURE AND MEASURES. My problem is: - Create the query that…
-
1
votes1
answer46
viewsHow to query a column in the database and view filtered in 3 html columns?
good morning. I have a question that I have never come across before with php and mysql. I have the following example table in mysql: ITEM : DEP : QTD ============================= 1 : T01 : 1000 2…
-
1
votes1
answer226
viewsSQL query where WHERE has 2 options
I intend to make an SQL query where WHERE has 2 situations, example: SELECT * FROM products WHERE name = "%Explosion%" OR tag = "%Explosion%" In this consultation I would specify that, first the…
-
1
votes2
answers74
viewsSQL query, count the amount of existing values of a Foreign Key for each corresponding Primary Key in 1 query
Example with 2 tables: table admin: columns: | id_admin | email | password | values: | 1 | ex@ex | 123 | | 2 | ex2@ex2 | 123 | table news: columns: | id_news | title | content | admin_id_admin |…
-
1
votes2
answers82
viewsSelect inside the Where leaving the query too slow?
I have the following structure: And my query is that way SELECT tbl_nfes.*, count(tbl_nfe_itens.pedido > 0) as v, tbl_nfe_itens.status FROM tbl_nfes INNER JOIN tbl_nfe_itens ON tbl_nfes.nfe =…
-
1
votes0
answers165
viewsLINQ return with repeated values
I’m having trouble with a consultation within my application. The values returned by my query are repeated, the same value appears 407 times, when the right one would have to be 407 different…
-
1
votes2
answers500
viewsSelecting data and organizing by 15min Sql interval
Good afternoon, I have the following query that returns the amount of vehicles on the track between a certain time. But I want to take this interval between times and set intervals between 15min.…
-
1
votes2
answers69
viewsQuery with more than one view field
I have doubts about how to perform the query displaying two fields, with only one. I have the Clients Table (id, name, date of birth) and the Transactions table (id_trans, id_clien, valor_trans). I…