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
-
2
votes1
answer905
viewsDisplay foreign keys from a table in the query
I have a table where each projeto may be related to up to 4 produtos. Main Table (foreign keys): IDPRODUTO IDPRODUTO2 IDPRODUTO3 IDPRODUTO4 Table produtos ID NOME To perform the display, I created a…
-
2
votes1
answer155
viewsSetting limit for query with UNION in Mysql
I would like to know how I create a limit for a query that uses UNION in Mysql, in my case I want to define the LIMIT 5 for the following query: $friends_a = mysql_query("(SELECT * FROM users WHERE…
-
2
votes3
answers2173
viewsHow to select all tables in mysql
What query makes me query a certain database in mysql that brings me all its tables?
-
2
votes2
answers325
viewsHow can I execute this query with Laravel 5?
How I would perform the following query in Laravel 5: SELECT *, (SELECT COUNT(`anuncios`.`cat-id`) FROM `anuncios` WHERE `anuncios`.`cat-id`=`categoria`.`cat-id`) AS `cat-total` FROM `categoria`…
-
2
votes2
answers87
viewsPass typed value to another method
I’m having a doubt when passing a typed amount. I’m posting here because I stayed the whole afternoon yesterday and found nothing. In first class: public class CompararLogin { private String nome;…
-
2
votes1
answer1201
viewsI must not show negative results
I created a query where I bring some information, among this information the last column returns positive, negative and zeroed values. I don’t want you to display the lines with negative values, but…
-
2
votes4
answers1229
viewsIs there any way to display the result of a query(mysqli) in the form of HTML?
I have already searched intensively for a solution to show the result of a mysqli query inside an html one, but I can’t find anything. I saw that it is possible to present the result through one…
-
2
votes1
answer760
viewsSQL Sum by periods
I’m having a question to assemble a query, following: In my sales chart I would like to return the sum per product period. Today I am doing this way: select YEAR(venda.data_venda) as Ano,…
-
2
votes3
answers76
viewsIs there any difference in performance depending on what you seek?
There is some difference in performance when searching the database, depending on the number of characters reported in the query? For example, if a query is made for any record that has the…
-
2
votes1
answer101
viewsDoubt how to query several tables with a word
I am setting up a search system, where the user type in a search box any word, Example "Programmer", mysql will have to search that word in various fields in various table, if by chance he finds…
-
2
votes1
answer375
viewsUpdate in a table with values from another
How to update the values of a table, using values taken from another table: UPDATE produto -- atualizar a tabela produto SET produto.quant = SUM(entrada.quant) -- produto.quant será igual a soma da…
-
2
votes1
answer158
viewsLINQ TO XML Query with Optional Widget
Hello folks I’m having a question to display the data of a file XML through a consultation LINQ , the problem is that I am trying to consult the data of the person but the mandatory filling and name…
-
2
votes1
answer971
viewsSQL date filter on timestamp
I have the following query: SELECT name, commission, timestamp, state_name FROM magry_awoaffiliate_commission c INNER JOIN magry_users u ON (c.user_id = u.id) INNER JOIN magry_virtuemart_userinfos v…
-
2
votes1
answer2421
viewsphp echo html tag as text
I have a query in php/oracle that shows the result in the browser, hides a tag "< /b>" while in oracle sql Developer presents everything ok. The expected: '___< /b>' What displays in the…
-
2
votes3
answers756
viewsHow to group results in a row?
I would like to perform a query About the table FICHA_EXAME with the following data: CREATE TABLE FICHA_EXAME ( FICHA smallint, EXAME VARCHAR(15) ); INSERT INTO FICHA_EXAME VALUES (1,'Hemograma');…
-
2
votes2
answers879
viewsPHP - How to make left Join with more than one record in the other tables not return repeated values in the columns?
I need to perform an SQL query in PHP, where I need to create a table from 9 other tables, joining all the columns with a LEFT JOIN, and with the 'Client' field as key between the tables. However,…
-
2
votes1
answer1233
viewsLeft Outer Join does not bring Null values
I have two tables: formulario_campo ( cod_campo, descricao, cod_formulario ) Filled with the following values - input_nome, Nome, 1 - input_sexo, Sexo, 1 The second table: —…
-
2
votes1
answer113
viewsSubquery with Linq
I need to consult with Linq on an object called Client. This object has a relationship with another object, which is a list of phones. For each of the phones, there is a type: 'Casa', 'Comercial',…
-
2
votes1
answer822
viewsUpdate in more than one line
I’m trying to ride a update thus: UPDATE cad_vendas SET canal ='9', parceiro ='9' WHERE cpf_vendedor ='CPF_VENDEDOR' and status_proposta_producao ='90' and forma_pagamento <> ''; but he won’t…
-
2
votes1
answer68
viewsQuery with Parameter causing timeout
I have a query that when running with ADO.NET it takes less than a second to return your data. When adding Parameters to this query, the return remains the same. However, when adding a type…
-
2
votes2
answers150
viewsUse one if with two selects
I am doing a query, in which the second query can give "NULL" or a value (if there is data). SELECT *, (SELECT tb1.image FROM ce_users_images tb1 WHERE tb1.iduser = users.iduser LIMIT 1) AS tmp1…
-
2
votes3
answers945
viewsProblem with php query because of quotation marks
I’m having trouble with a php query as follows, Example: INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal','Tom B. Erichsen','Skagen…
-
2
votes2
answers74
viewshow to make this query sql
code is PK in both tabela1: cliente codigo, nome, municipio tabela2: notafiscal codigo, numerodanota, cod_cliente I want to list give a Count(*) on all notafiscal where cod_client.municipio = 10 how…
-
2
votes2
answers1258
viewsCount values with specific data in MYSQL
I have a huge list of values that I need to count, the example is, I have 4000 barcodes and those 4000, 2000 are marked in the column out of stock with a yes. Better explanations In total barcode…
-
2
votes1
answer332
viewsQuery with variable date in Mysql returning empty
I need to make a query in Mysql setting 3 variables,when only in the case of right integer,more when I include empty return date ta. Follows my query,what could be doing wrong? SET @tipo = 47; SET…
-
2
votes2
answers3352
viewsHow to fix accentuation query sql server data
Good morning! Guys, how do I correct the accents of the data coming from a select in sql server. For some records that were to come as Sergio, is coming SÃ rgio.
-
2
votes2
answers163
viewsError message when closing the application
I have this code that I use in a login screen, that when the user uses the correct password, it directs to the main screen, until then everything ok, works perfectly, but when I fecho the…
-
2
votes2
answers2006
views -
2
votes1
answer198
viewsaccess - subtraction in query duplicates values
I coded the following queries: Somantradastotal: SELECT artigos.Nome, Sum(Entradas.quantidade_ent) AS [Total Entradas] FROM artigos INNER JOIN Entradas ON artigos.Cod_artigo = Entradas.Cod_artigo…
-
2
votes1
answer239
viewsCreate and query Wp
Is it possible to create a table in the Wp database to enter values and change them, or would it block me? I wanted to create a simple table only to validate, insert a number and if necessary to…
-
2
votes2
answers530
viewsHow to make an SQL query with some blank criteria?
I am creating a filter for a database search in a PHP application and obviously I have numerous criteria, but, I have only been able to work with one criterion. Code: select codigo, despesa, data,…
-
2
votes1
answer637
viewsHow to compare the values of a column with the average of these values in SQL?
I have a column of books, and I just want to show the books that the price is higher than the average of those prices, how to do that? The name of my column is price, and I can’t put a where price…
-
2
votes1
answer294
viewsError Code: 1054. Unkowm column
I’m looking for a value from an account I made in SQL: (Valor - (select Visibilidade)) AS Diferenca When I try to consult: Diferenca <= 500 It presents the following error: Error Code: 1054.…
-
2
votes2
answers2233
viewsHow to make Join of 2 tables without repeating data?
I have 2 tables, a call SR7010 and another call SR3010. The primary key of the two is the field R7_MAT and R3_MAT. The query I’m trying to execute is this: SELECT R7_FILIAL, R7_MAT, R7_DESCFUN,…
-
2
votes5
answers2617
viewsSelect last dates of each SQL month
I would like to perform an SQL to get from a list of dates the last day of each month. Example: From a list 01/01/2016 until 31/12/2016 return the last days of each month: 31/01/2016, 28/02/2016...…
-
2
votes1
answer74
viewsDoubt - Insert SQL Server 2012 table
I need to insert some information in the table called task, however, only when a certain condition is accepted that in the case of these two date fields, I put it for today for example if it was…
-
2
votes1
answer445
viewsGroup query by similar but non-identical records
I need to migrate a database (from SQL Server for PostgreSQL and I’m creating a ETL interactive in PHP to make this change), which is about 10 years old, about 2 million records in the clientes that…
-
2
votes1
answer344
viewsPick up only the days of the current month
I have the query below where it is made on the current day, how could make the same query in the current month until today, example: 01/09 to 13/09, but so that tomorrow’s consultation is: 01/09 to…
-
2
votes1
answer168
views -
2
votes1
answer158
viewsSQL - How to make multiple Inserts in a table with the result of a SELECT * of another table in a query
Hello, I would like to know how to make several Inserts in a table with the result of a SELECT of all id of another table table that are not as foreign key in the first table. I already have the…
-
2
votes1
answer101
viewsConvert query to Sqlserver
I have the following query for the Oracle bank: select xmlagg(xmlelement(e, d.delinha, '').extract('//text()') order by d.nulinha).getclobval(). I need to convert to run in the Sqlserver bank, but…
-
2
votes2
answers176
viewsSelect a certain amount of data for each status type
Billy Jow here! On my table historical I have a field status that can assume four possible values: 'EVALUATE', 'FAILURE', 'REEVALUATE', 'SUCCESS' I wish to select 20 records from each status where…
-
2
votes1
answer192
viewsMYSQL - Select 2 tables
Good morning Personal! I have a problem when performing a query in MYSQL, and the query I am using is not displaying the desired results. Follow the example: TABLE: CLIENTES (codigo_cliente, nome,…
-
2
votes3
answers102
viewsTake Report with zero months
I have a query in which I take monthly deposited values it takes everything it has in the base and shows the months that were entered in the base. I would like to do different I would like to show…
-
2
votes1
answer452
viewsSQL, subquery if null
I’m doing a query, but I didn’t want it to return NULL. What I got is this: select ifnull(sum(job_withdraw_qty),0) as total, ( select IFNULL(sum(job_withdraw_qty),0) from job_positions where…
-
2
votes3
answers58
viewsSQL Query - Doubt Condition Dates
Guys, good afternoon! I’m having difficulty in the consultation below. I want you to bring all the tasks only when their salary (tarexpiration field) is equal to the month after the opening date…
-
2
votes1
answer38
viewsHow to return the expected result in this query?
Good afternoon, you guys. The case is as follows: I have a table with 2 blogs of category "auto" and part of the title "Hackers" so whatever my query, can not return more than two results combining…
-
2
votes1
answer451
viewsIs it possible to query "INSERT INTO table SET field = 'value' " in Postgresql?
It is possible to run the query INSERT INTO nome_tabela SET nome_campo = 'aaaa' in the Postgresql database. I had to migrate a virtual store made in PHP with bank Mysql, for Postgresql. The bank…
-
2
votes1
answer110
viewsSQL query using several times the same function
I have a function that converts the identification of a version to number, example, of 1.0.0 for 10000, because I can filter the results. Function: CREATE OR REPLACE FUNCTION…
-
2
votes1
answer96
viewsQuery - Comparison of Distinct Bases with equal columns
How would a query that selects between two tables according to the value of a specific column ? For example: I have two tables that contain account number and Balance, I need to know which accounts…