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
-
0
votes3
answers64
viewsDifficulty when mounting SQL query
Whoa, guys. I’m having difficulty to mount a query in Mysql. The thing is, I have a table with the following structure The time_orange and time_blue columns store system user ID’s. I need to search…
-
0
votes1
answer84
viewsPHP: Group data without using group_by
Does anyone know how to group data without using group_by in consultation? I need every 10 loop results (foreach), create a div, that is, 10 records within each div, I don’t care about the values.…
-
0
votes1
answer1846
viewsHow to use the Contains method in a search using the Entityframework
I’m trying to make the following consultation sql, using the Entityframework: select * from pedidos where pedidoID not in (select pedidoID from agendamentos); I conducted some research and…
-
0
votes1
answer151
viewsPick element selector created at runtime
I have a system that lists the fields and attributes of a table through javascript and ajax up to there everything, only that the elements created and listed in precise runtime manipulates lós…
-
0
votes3
answers90
viewsHow to do more than one select in the same query in different BD tables?
The problem is this: I have the tables: Which are foreign keys in the following table: And I need to pull all the column names "modelo_conector", "nome_genero_conector" and "tipo_de_conector" and…
-
0
votes2
answers82
viewsSQL Updating Wrong Value
I am creating a QUERY to change every day of the dates registered in the BD to the last day of the month of that record... what happens is that when I play the QUERY selecting a record in the month…
-
0
votes1
answer129
viewsOrganize Period column in SQL in ascending or descending form
Staff I have the following question/problem I’m doing a select on some accounts and organized by the name of the file, but I need to organize for the period but I’m not able to because it is not a…
-
0
votes1
answer402
viewsHow to return data array with Join in Laravel with the DB class?
I need some help with that SQL of Laravel: $process = $db->table('processo')->where('nrprocesso',$id) ->leftJoin('viatransporte', function($viatransporte){…
-
0
votes1
answer13
viewsHelp with ORDER BY clause by string
I have the following select command: select nome, case grau when 0 then 'QS' when 1 then 'CI' when 2 then 'CDC' when 3 then 'QM' end grau, case faixa when 0 then 'NÃO' when 1 then 'SIM' end faixa,…
-
0
votes1
answer97
viewsHow to remove, insert, or change a single character in a field in Mysql?
I have the following table in Mysql: Id | comida | preco 1 | batata | 325 2 | carne | 3.10 3 | speculoos | 3.00 I wish I could change the points according to the needs below: If the food = potato,…
-
0
votes1
answer1537
viewsMedia calculation between SQL Selects
Good Afternoon Please help me out Error in the Syntax Msg 102, Level 15, State 1, Line 2087 Incorrect syntax near 'TAB'. --TARIFAS --Calcular Média Tarifada BEGIN TRY DROP TABLE #TARIFASINDMETRO END…
-
0
votes2
answers2427
viewsSQL Query VBA Excel
Good afternoon! I have a problem with a query in Access via form. The Form is from Excel vba, which connects to the database. Below is the complete code. This is the code of the button. Clicking…
-
0
votes1
answer133
viewshow to convert my object into a string?
I did a function to insert the data into the database, but since I am using classes, I have to insert a class object into the database that will contain the data of the person in question, only that…
-
0
votes2
answers48
viewsError picking a select result
Can someone help me with this code. Makes that mistake: Warning: mysql_fetch_array() expects Parameter 1 to be Resource, Boolean Given in /var/www/xxx/teste.php on line 14 Notice: Undefined…
-
0
votes1
answer23
viewsJoin in three tables does not show all results
SELECT * FROM produto_unidades join produto_notas on produto_notas.id = produto_unidades.produtoNota_id join produto_licitacoes on produto_licitacoes.id = produto_notas.produtoLicitacoes_id where…
-
0
votes2
answers5013
viewsHow to add two columns?
I have 2 subselects, in SQL, that bring 2 different information, with the sum data. How to add the 2 "sums" and bring in a new column, or a single column? CASE WHEN sd3.D3_UM = 'PC' THEN (SELECT…
-
0
votes0
answers254
viewsConnect By no Sqlserver
I have a query that works on Oracle but is not working on SQL Server. The table I have recorded has an initial date and final date on the same line, but when it goes from one day to the next I…
-
0
votes2
answers59
viewsSELECT Cursor using top1
I need to return only the highest value of one of the lines below, taking into account that I also need to submit the order code. I tried to rotate via cursor but without success. The cursor would…
-
0
votes2
answers35
viewsCreate a grouped query by month
I have a field in my database (dt_nf) that is DATE type. I would like to do a query that groups not by date, but by month and year, but I’m not getting it. My code is like this: SELECT…
-
0
votes4
answers131
viewsMAX with LIMIT does not give the correct result
Imagine the following lines in my Mysql database: I want a query that displays the name and age of the person who has the highest age in the table, for that I did this query: SELECT nome, MAX(idade)…
-
0
votes1
answer91
viewsSelect limiting query, and does not display the latest queries
In this script, it is limited to the display of 6 queries in the SELECT variable $quantidade_pg = 6, I used the IF to inform that all news situations other than 2 (unpublished) should be displayed.…
-
0
votes2
answers56
viewsDelay in loading some records
Hello! We work with Sugarcrm. Anyone not familiar with Sugarcrm is a CRM made in mysql and php that uses the Zend framework. We used the opensource version and made some customizations. I’m having…
-
0
votes0
answers51
viewsPagination query with LIKE function
good afternoon. I have an error in paging query when I pass a search parameter. Here’s the problem: When I’m on page 2 and I do a search for an item on page 20 of mine sql returns nothing. Follows…
-
0
votes1
answer62
viewsHow to make an appointment to know the averages of people a day of a week
Hello, I would like to know how to make a query (Query) in the Oracle database to know: What is the average number of guests per day of any week. Below is the bank script: CREATE TABLE…
-
0
votes1
answer87
viewsMultiple SQL query
I’m not very experienced with SQL language, as I could make a query work this way: SELECT *, ( SELECT marca.* FROM marca WHERE marca.id = produtos.id ) AS nome_marca FROM produtos WHERE id = 5 What…
-
0
votes0
answers490
viewsinsert into two tables at the same time with php
I’m in trouble. I have the tables usuario and aluno which are related by primary and foreign key. I want to make an insertion with php to insert data into the two tables, the idusuario table usuario…
-
0
votes1
answer169
viewsAverage value of entries up to 100km sql
I’m making a query that brings the average values, as long as the distance is up to 90km: SELECT avg(valor),(6371 * acos( cos( radians(-23.2632227) ) * cos( radians( lat ) ) * cos( radians( lng ) -…
-
0
votes1
answer160
viewsKnow the position on a listing
I’m wearing this query to know a user’s feedback quantity: $comentarios = $pdo->query("SELECT * FROM topicos_comentarios WHERE autor='".$ver['autor']."'")->rowCount(); However, I would like to…
-
0
votes1
answer839
viewsReturn data from my table by formatting in html
I have a function within my class to list data; below follows the code: public function listadados(){ try{ //retornar um array $sql = "SELECT * FROM web_cadcli"; $lista =…
-
0
votes1
answer106
viewsRow results in columns ( SUM )
Good Afternoon, I have a big question in my query, I have a table with the following info: I would like the following result I need the result to be the total value of (forms of payments) per day,…
-
0
votes1
answer609
viewsConvert SQL query to Query Builder (Orange)
I would like to convert the following query SQL to Query Builder (Laravel): $duels = DB::select('SELECT r.id, r.name FROM tournaments t INNER JOIN duels d ON t.id = d.tournament_id INNER JOIN riders…
-
0
votes3
answers378
viewsDoubt SQL query d
I am wanting to perform the calculation in sql query where the result is the number of open calls divided by the number of working days chosen period. Ex: They were opened 200 calls in the month and…
-
0
votes1
answer78
viewsWhat to call Named Query in main? JPA
Guys, please, could someone show me how to call in the main @Namedquery class of another class. Follow the example: @Entity @Table(name="edificio")…
-
0
votes1
answer239
viewsSyntax error near limit
Can someone help me? I have the following query: select coluna1, coluna2, coluna3 from tabela where coluna2 > 0 order by coluna3 desc limit 10 And when I execute the following error appears: Msg…
-
0
votes1
answer41
viewsHow to perform a has_many interaction query in Ruby on Rails
I’m having difficulty searching with has_many interactions in ruby on Rails. Goal is to search all vehicles that have no fines type 'guy'... The problem is that the query I made still returns…
-
0
votes0
answers43
viewsQuery with return #num! for columns string in excel
I made a query in excel that when running it in VBA was generated a result. Among the generated columns, one that was text appeared with #num! in all values that were not empty before. I believe…
-
0
votes1
answer129
viewsHow to concatenate the return of a query to a string from another mysql
I have the following query: SELECT id AS CODIGO, nome AS NOME, versao AS VERSAO, build AS BUILD, data AS DATA FROM sistema INTO OUTFILE 'D:/servicos/export/exportaVersao.csv' FIELDS TERMINATED BY…
-
0
votes1
answer1114
viewsHow to decrypt records from an SQL column - Query
Good morning! Guys, how to decrypt records from a column in an SQL query. The field I want to decrypt is the coluna MAX(A.Descricao) [Descrição da Última Providência]. SELECT…
-
0
votes1
answer496
viewsCheck for list records in the Entity framework
I have the following code: var ret = Monitoramento.List .Include(p => p.CD) .ThenInclude(p => p.CargaEntrega) .ThenInclude(p => p.CargaEntrega.Motorista) .ThenInclude(p =>…
-
0
votes1
answer187
viewsSearching character in Specific Position - SQL Server
Hello, can anyone help me? I am building a query and I came across some problems in the way the bank was structured. I have a base with several phone numbers, and I need the 5°digito to be = 9. I…
-
0
votes1
answer547
viewsUse While twice or more for the same Select?
I’m setting up a listing page and registration of output products and I’m having trouble at the time to pull up the information and do the while for the second time. Example: $sql_for = mysql_query…
-
0
votes1
answer3060
viewsError - Query: The sub-query returned more than 1 value
I am new to SQL and I have the following error in my query: "The sub-query returned more than 1 value. This is not allowed when the subconsulta follows a =, != , <, <= , >, >= or when it…
-
0
votes0
answers586
viewsRemove SQL Server special characters
how do I remove special characters from a string in a query in SQL Server with tags in html, xml and others? Current result: <!--[if !mso]><styl>v\:* {behavior:url(#default#VML);}o\:*…
-
0
votes1
answer209
viewsReplace Iframes
Hi, I wanted help to put together a script but I don’t know where to start. I have a movie site, where I put video iframe. I wanted a script that identifies all these iframe and add an image about…
-
0
votes1
answer2984
viewsOracle sql - Expression not found
What I’m trying to do is this: List the names of the Cds that have a sales price greater than 10.00 reais or the label is code 3, ordered alphabetically by decreasing the names of the Cds. Show CD…
-
0
votes1
answer134
views -
0
votes1
answer60
viewsNot bringing the records - Query SQL
Good afternoon! Guys, below is the query that is to bring the amount of active clients in one column and the amount of locked clients in another column, however, when running the query, comes null…
-
0
votes0
answers52
viewsOR logic operator in sparql
I’m trying to build a sparql query using Or, like: SELECT ?a ?b ?c WHERE (?a :property ?b **OR** ?b :property ?c **OR** ?a :property ?x OR .....) ... ms I cannot use, because it throws the following…
-
0
votes1
answer63
viewsSQL "Where" problem
I am doing a query in SQL and as a constraint I want the query to return the data from the first day of the previous month until today. For example: If I run today (10/04/2019) the query, will…
-
0
votes1
answer673
viewsSQL to count records that have a field
Good afternoon, I don’t know how the rules of the topic work, I asked for help on a previous topic and one of the members ended up helping me only that I wanted to ask another question about the…