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
answers53
viewsHow to add variable in query as column?
How do I add the variable $pesq as column of a query ( not query) query? $pesq = mysqli_real_escape_string($dbcon , $_POST['pesq']); $pesquisa = mysqli_real_escape_string($dbcon ,…
-
1
votes1
answer383
viewsUsing Elasticsearch, how to obtain data between certain hours using range
Hello, I am using Elasticsearch, and my query is not searching for the information I want. { "query": { "bool": { "must": [ { "range": { "date": { "gte": "2016-04-29 00:00:01", "lte": "now" } } } ]…
-
1
votes1
answer653
viewsCuriosity - PHP and Data Query Limit
Today while doing an appointment by Phpmyadmin of the type SELECT * FROM tabela , I noticed that after making a query in the database automatically the query gets the LIMIT, in this way SELECT *…
-
1
votes0
answers67
viewsRavendb - How to query words ignoring accent
I need to make a person name query ignoring the accent. Ex: in my document I have a record with the name "Leticia". If I refer to "Eticia" the result is empty. The behavior I need is to find the…
-
1
votes1
answer706
viewsSplit date ranges into weeks
Would have some simple way to extract the weeks given a range of dates, for example: Start date: 01/07/2017 end date: 30/07/2017 Given the above dates how could you automate the extraction of the…
-
1
votes0
answers282
viewsfunction that returns the name of the key field of a query (tfdquery), Delphi XE8
I’m preparing a CRUD in Delphi and need to do a function to find the key field (Keyfield) of a certain record located in the query. The idea is to replace the id field required by Locate with this…
-
1
votes0
answers30
viewsReload failing in a few moments
I made a script to set an image as cover, the script works perfectly and I programmed the same to perform a Reload on the return, but strangely this Reload fails in a few moments, for no apparent…
queryasked 8 years, 5 months ago adventistapr 5,498 -
1
votes1
answer293
views1060 - Duplicate column name 'NULL' in a Mysql query
I am trying to execute this query, and it always gives me the following error: 1060 - Duplicate column name 'NULL' INSERT INTO ce_coins_issued (idc, idu, year, ltr, issuing, status) SELECT * FROM…
-
1
votes2
answers348
viewsCheck the number of people per age
How does the consultation to know the total number of people in the age range from 0 to 5 years, and if you do not have any child with a certain age, enter 0; select idade, count(*) as qtd from…
-
1
votes1
answer241
viewsHow to insert data using query in a for loop?
I’m trying to insert data into the mysql DB being that some data repeats and others not so who would command the number of executions would be the for, but it is not running the query inside for. I…
-
1
votes1
answer89
viewsDrop Index with SQL variable
I’m an inexperienced grasshopper and I’m looking to make an automatic script for myself. This script I created in batch and I can go smoothly to the installation of SQL, database restore and…
-
1
votes1
answer375
viewsCalculate average with Pivot result
I have a query that returns the grades of students in certain tests. The amount of test may vary. I use the Pivot command to transform test names into columns and so organize test/note, as shown in…
-
1
votes2
answers449
viewsHow to create summation with "sum" with multiple queryover columns
People need to create a query with queryOver(Nhibernate) C#, to add more than one column. Example in pure sql: SELECT SUM(coluna1 + coluna2 + coluna3 + coluna4) FROM tabela First I did so: Tabela…
-
1
votes2
answers64
viewsHow to add up the amount of records in which the penultimate record enters the Where?
I need a query, in MYSQL, that checks the penultimate record and that this record is equal to a certain value, and that counts the amount of records found. Ex: penultimate record is John’s. I need…
-
1
votes3
answers62
viewsGet only 1 of each journey
Well, I have a table called tabelajornadas. In it, I have several records, and in which I have the column jornada, who’s kind int. In it, they contain several records with the same number in the…
-
1
votes3
answers227
viewsHow to store the number of rows found from a Mysql query in a variable
I have a Side Menu on my page and I want to display an alert text to the user, indicating when they have new messages and how many of them. For this I made the query in BD and it returns me…
-
1
votes1
answer1533
viewsSplit column into multiple rows (split)
I have a table cidade_bairro with several cities and neighborhoods. I want to transfer this data to a new table, but in several lines instead of being in one. EX: Cidade Bairros<br> SP |…
-
1
votes1
answer38
viewsQuery to get all records regardless of whether they exist in another table or not
I’m running an app from a store where users can leave equipment to be fixed. So I made a php to search by name those users who have already left some equipment: $sql = mysqli_query("$conexao, SELECT…
-
1
votes1
answer107
viewssystem with 2 databases , returning empty mysql php queries
I have a system where I have a user base which is a unified base in a bank, and another base in the system. In my pages I call them so: <?php include("conn_user.php"); include("conn_sys.php");…
-
1
votes1
answer287
viewsPass a php array in a query and return multiple results
I want to pass a dynamic POST array of type: array(2) { [0]=> string(1) "1" [1]=> string(1) "3" } For an SQL query where it returns multiple results depending on the string values in the array…
-
1
votes2
answers444
viewsJoin returning many records
Hi, I’ve researched here about this error and I haven’t seen one that fits my problem, so my problem is that I have two tables, I need to get some information from table B and insert in the query…
-
1
votes2
answers703
viewsHow to return the entity number of a table using JPA and the COUNT function?
I am using the Eclipselink implementation and cannot solve the following query that must be wrong: Query query = em.createQuery("SELECT e , COUNT(*) FROM Empregado e"); Integer resultado = (Integer)…
-
1
votes1
answer187
viewsAverage values where fields are equal
I have a table, in bank mysql, that receives some data regarding evaluations. How can I calculate the average of these evaluations directly on query, based on the question? I tried several ways,…
-
1
votes1
answer202
viewsError run UPDATE SQL Server
When executing the update statement below is occurring the following error. What can be? Msg 116, Level 16, State 1, Line 3 Only an expression can be specified in the selection list when the…
-
1
votes1
answer297
viewsHow to hide fields in queries using eloquent Join method
From a question, I was given a way to make queries with children objects using the Join of the eloquent, The query is below: $dados = Roda::join('veiculos', function($query) {…
-
1
votes2
answers454
viewsHow to convert Float to String using LINQ for Entity?
How to convert Float to String using LINQ to Entity? I need to convert a field from my database that has the float type to the string type in my C# using the LINQ. Try using Convert.Tostring,…
-
1
votes1
answer117
viewsTransaction in Postgress on Nodejs
I’m looking to encapsulate my SQL execution in the Postgress database. My initial wish is to call a method to execute a specific query and another method to execute a transaction of various queries.…
-
1
votes2
answers785
viewsHow to show the result of a query based on the result of another?
Consultation A: SELECT V.CHAPA AS CHAPA, F.NOME AS NOME, V.DATA AS DATA, DATEDIFF(mi, MIN(BATIDA), MAX(BATIDA)) AS DIFF FROM V_BATIDASANTIGAS AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA…
-
1
votes0
answers40
viewstext_field com Where to search in Rails
I’m starting to study Rails and am trying to search by name and date on a list. I would like to present on the screen inside the show page this search by name and date where I am trying to create…
-
1
votes1
answer375
viewsSubquery Returns more than 1 Row Mysql
Follow the code below that is causing the error quoted in the title: select (select id from message where user_from = tempMsg.user OR user_to = tempMsg.user) as id from tempMsg How can I fix it?…
-
1
votes1
answer31
viewsCheck the difference between unlisted results and identify which day of the week is the date
I have the following appointment: SELECT V.CHAPA, F.NOME, V.DATA, MAX(V.SEQUENCIALBATIDA) AS BATIDA FROM ARELBATIDATRANSITOVIEW AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA WHERE V.CHAPA =…
-
1
votes1
answer642
viewsDifference of days between records and display only results > that 14
I have the following appointment: SELECT V.CHAPA, F.NOME, V.DATA, DATENAME(dw,V.DATA) AS DIA, MAX(V.SEQUENCIALBATIDA) AS BATIDA FROM ARELBATIDATRANSITOVIEW AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA…
-
1
votes1
answer38
viewsConsultation with combined criteria
I’m trying to assign more than one search criteria in the database and I can’t find anything that can help me. I’ll explain it better: I have a database with a "city" field, where I want the daos…
-
1
votes1
answer62
viewsHow to avoid performance problems with tables that contain a lot of data?
I am developing a payroll system, in which there is a "problem' in one of its tables. Because, to control the discounts on the holerite of each employee, I thought to create a table with the name:…
-
1
votes1
answer83
viewsSUB-CONSULTATIONS IN SQL?
Using the BD below, how would return the name of the person who rented the date '2016/11/17'. Name is in the person table and the date in the loan table. CREATE DATABASE escola; USE escola; CREATE…
-
1
votes1
answer31
viewsHow to modify this query to get the desired result in Codeigniter?
I have an SQL that returns to me the following: 1: Hacker And Automobiles OR 2: Food and I need her to return to me: 1: Hacker And 2: Cars or Food The code I have so far is: if(!$final['termo'] ==…
-
1
votes2
answers140
viewsProblem with IN condition in sub-select
I have the following problem; I’m trying to do some research and include the value of WHERE major in a sub-select, but the result is always reported as 0, and there are records. Part of query that…
-
1
votes0
answers133
viewsHow to pass parameters for a query in a repository?
I’m creating a series of classes that return listings in Java (Android). I am concerned about the format of the parameters that will be passed. My initial approach has been to pass a Map with…
-
1
votes1
answer61
viewsDoubt - SQL Server 2012 Query
People, in the query below want to put a condition within the Where that bring only the tasks that are due two months after the opening date. For example. The task 11111 was opened on 01-11-2017 and…
-
1
votes2
answers1807
viewsINNER JOIN with equal fields in a table - Error: #1066 - Not Unique table/alias: 'tb_usuario'
I have 3 tables as follows: At tb_usuario, I have two types of users (buyer, seller) in an ENUM field to differentiate the type of user. In the shopping cart I have the user Ids, product and…
-
1
votes1
answer251
viewsError in update sql: Subquery returned more than 1 value. This is not permitted when the subquery Follows
I am performing a query to change the net cost of a product according to a brand, however, I get the following error message: Subquery returned more than 1 value. This is not permitted when the…
-
1
votes4
answers1103
viewsSELECT with two results
Table: PEOPLE id - nome 1 - BEATRIZ 2 - MARIA 3 - CARLOS 4 - MARIA 5 - JÉSSICA 6 - HENRIQUE How do I make a SELECT that gives me as a result a list of the names ordered by ID descendente, however, a…
-
1
votes1
answer131
viewsQuery string works in Phpmyadmin and does not work in PHP
I have the following query that picks up a date, was tested on phpmyadmin and the Heidisql program successfully: Query Mysql set @rn:=0,@grp:=0,@prevdate:=''; from (select DataEncomenda, @rn:=@rn+1…
-
1
votes1
answer155
viewsQueries Builder Problems (Query Builder) in Laravel 4.2
Hello, I’m having trouble generating a querie using the Querie Builder of Laravel 4.2, the difficulty arises from the need that the resulting sentences for search in the database are within…
-
1
votes1
answer219
viewsmysql Rank function grouped for a COUNT
I have 3 tables in MYSQL represented here as an example: I need a query that returns a RANK of contracts made grouped by commercial in a given period of time, for example: A query that returns the…
-
1
votes1
answer26
viewsProblem in mysql query
I’m having a problem doing a mysql query. I want to select the id and name of everyone present, except those already in the booking table. SELECT DISTINCT tb_presentes.id_presente AS value_id,…
-
1
votes2
answers611
viewsUpdating multiple Mysql lines and fields
I built a Mysql Query in order to update a field in several rows of my Mysql table. It was as follows: update produtos set (nome) = case codigo when 5 then 'teste 1' when 6 then 'teste 2' when 7…
-
1
votes1
answer1231
viewsHow to create this view in postgres?
CREATE VIEW grafico AS SELECT AVG(realizacao) , AVG(estima), AVG(fisiologica),AVG(seguranca),AVG(social) FROM necessidade; I am trying to create a view that brings the average of five columns of the…
-
1
votes1
answer69
viewsMedia Query for different zoom levels?
I would like to use values 'in' in Media Query, only for different types of zoom in the browser like 100% 125% 175% and so it goes. What values should I use?…
-
1
votes3
answers75
viewsConditional for registration selection
am with a question for selecting a record from a table and would like a help. An example of the structure of the following table: idhistorico_professional | idprofessional | funcao | inicio | final…