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
-
3
votes1
answer280
viewsWhere x whereRaw What’s the difference?
I tried to read Laravel’s documentation, but I didn’t really understand the difference. I also tried to search for other links but, I usually see topics in forums asking for help on the use and…
-
3
votes1
answer59
viewsDifferent ways to do a query that performs an SQL merge
I learned to do SQL queries with joins as follows: SELECT u.NOME, e.RUA FROM usuarios u, endereco e WHERE e.ID_USUARIO = u.ID ORDER BY u.NOME As you can see, the query searches the name of users and…
-
3
votes1
answer140
viewsQuery - Bring 5 major records
I have the query below, where I need to bring only the 2 largest columns that have the highest values. Today is coming out like this: Conciliacao Extrato Integração 150 140 80 That is, I wanted to…
-
3
votes4
answers1722
viewsHow to recover a value from within a tag in XML?
I have a table called SPDNFE with a column DsXML which contains all the contents of a Xml. Query: SELECT top 1 SPDNFE.DsXML FROM SPDNFE where SPDNFE.CdIdNFe =…
-
3
votes2
answers1482
viewsSQL: Doubt in the Relationship between Tables
I am creating an academic system that consists of a virtual restaurant menu type, for this, I created three tables in the bank: Table of Menu Items: CREATE TABLE ITEMS( ID INT PRIMARY KEY NOT NULL,…
-
3
votes3
answers144
viewsHelp with select
I’m using the remote select down below: select f.no_equipe, h.no_pessoa_fisica, a.no_cidadao, d.dt_ficha from tb_cds_cad_individual a, tb_cds_atend_individual b, rl_cds_atend_individual_ciap c,…
-
3
votes1
answer3146
viewsTurn rows into a select column - PIVOT - SQL Server
I have an SQL query that returns the following result: Consultation +--------------------------------------------------------------------------+ | CONJUNTO | TIPO | FILHO | PAI | TIPO_CONTEUDO |…
-
3
votes1
answer43
viewsCreation of Trigger
I need to develop a Rigger in which any change that occurs in one of these fields below the Task table should send the task information to the Instruction table. TASK TABLE TarefaID Vencimento…
-
3
votes2
answers82
viewsSQLSERVER compare two groups of results
I need to make a query in sql server where I have to "connect" stocks to companies. The stock has 'n' products attached to it, and these products have 1 category linked to it. The company also has…
-
3
votes1
answer49
viewsDoubt - Query SQL Server condition
Guys, in the query below is bringing in the following way. However, I want you to bring only the 'YES'. The difficulty is because it is a subselect with case. I bring where? No Where or a having?…
-
3
votes1
answer135
viewsQuery using Hibernate does not bring record
I’m trying to query the HSQLDB database using Hibernate but I’m not succeeding. When I do: session.get(Usuario.class, new Integer(1)); The query is made because it shows the query mounted by…
-
3
votes2
answers351
views -
3
votes1
answer283
viewsSelect Electronic Point Record (SQL)
How can I gather only the first and last appointment, where a staff member can have X Appointments and even appointments the next day? As the example below +------+--------+-------+-------+ | FUNC |…
-
3
votes2
answers171
viewsSelect within select where condition exists
Good morning, With a table of articles with the fields Reference | Quantity | Price | Referencesociated | I wanted to have a select that would do the following, with the example: Example Table of…
-
3
votes1
answer126
viewsPerformance according to box control modeling
I am making a system for daily box control, which allows launches/deletion of values. Below is the table that will store the values, filled with some data to exemplify. There are more fields, but…
-
3
votes0
answers264
viewsRemove HTML tags with regexp in query
I am trying to query Mysql 5.7 using regexp to ignore HTML tags, so far I have the following query: SELECT * FROM question WHERE question.enunciation REGEXP '[^<|</]center[^\>]' = true…
-
3
votes1
answer214
viewsChecking crashed tables in Mysql with PHP
Here in the company there is a structure with at least 20 servers, each server has at least 20 databases, and each database must have between 40 to 50 tables. For such a structure, rotate the…
-
3
votes1
answer148
viewsGet a result that appears in 1st position if you have a value specified in SQL
I need to create a query that follows some rules and they are: gsm repeat sending be different status who is with ANOMALY and appears as the first result (over the others) I’ll give you an example…
-
3
votes2
answers299
viewsDo I need to open a Mysql connection for each PHP query?
I need to get several variables based on my bank to mount a full Dashboard. For example, I need the number of lines, the average value of a given field and the same average value only per FU. The…
-
2
votes1
answer644
viewsHow can I insert the results of a query into another table?
I am executing the following database query directly from the phpMyAdmin: SELECT shop.id AS cart_details_id, shop.id AS cart_id, e.name AS client_name, e.nif AS client_tin, e.addr AS client_address,…
-
2
votes2
answers210
viewsHow to change a query so that it is executed for each row of table X?
I have the following query of the working database: SET @orderid := '1'; INSERT INTO `cart_lines` ( `line_id` , `cart_id` , `book_id` , `book_reference` , `book_name` , `book_type` , `unit_price` ,…
-
2
votes1
answer577
views -
2
votes1
answer5300
viewsQuery server problem has Gone away
An error occurred to me in the Query part mysql_query(): MySQL server has gone away What kind of mistake is this? Query: $sqlinsert = "INSERT INTO tb_trabalhador…
-
2
votes2
answers491
viewsQuery Select Option PHP
How to do a query with select option that the user can choose? On the frontend: <form method="post" action="Procurarquery.php" enctype="multipart/form-data"> <span class="LABEL4CSS"…
-
2
votes1
answer129
viewsSearch ignoring accent on AWS Cloudsearch
I’m using AWS Cloudsearch, and my question is about how I perform a simple search, like "bone", and it returns the records containing "cap", or "tennis" and return the records with "tennis". I read…
-
2
votes3
answers22309
viewsIF condition inside a WHERE - ORACLE PL/SQL
See below for details of the problem in question: CREATE OR REPLACE PROCEDURE NOVODIA.PRC_PACIENTES_INATIVOS_95 ( --PARAMETROS IN_CPF IN VARCHAR2, IN_CARTAO IN VARCHAR2, OUT_CURSOR OUT SYS_REFCURSOR…
-
2
votes1
answer129
viewsProblem with mounting SQL query
I have a table of "disciplines", a table of "students" and a table of "students" where these students may be enrolled in one or more disciplines. These disciplines are shown as checkboxes on the…
-
2
votes1
answer259
viewsJoin with Codeigniter Active Record
I made a query that is running ok and I am passing to the Active Record of Codeigniter but it is not working because of a Join that is a bit out with conventional, does anyone have any idea what…
-
2
votes1
answer142
viewsList grouped and filtered data
I’m performing a query in PUBS, the database that is used in MSDN tutorials for SQL Server, and I can’t find a way to do it. The two tables I use are the Publishers and the Titles who have the…
-
2
votes1
answer60
viewsProblem - Linq SQL Server: Unwanted query in database when assigning value in a database derived field
All right, guys I have the following problem: I have the method below that only has the job of updating a field in the database, the class t_sap_log_jobs that is passed as parameter was created…
-
2
votes1
answer2941
viewsHow to do custom query with JPA+Hibernate
Hello, I would like to know an elegant way to make a custom consultation using JPA. Basically I want to run the query and that it return me an object list, but usually it will be a query with N…
-
2
votes1
answer526
viewsIqueryable select data from multiple tables
I have a queryable (Linq to entities) in the Entityframework and I’m not able to pull data from two or more tables. For example: var model = _service.List().Where(m =>…
-
2
votes2
answers1700
viewsQuery to return only higher values
I have the following table: Contract | Code | Year 13 7800 2015 12 7800 2014 12 7800 2013 12 7801 2016 12 7801 2013 12 5102 2017 I am trying to make a query to return the result below, that is, the…
-
2
votes1
answer4343
viewsQuery works in the database but not via code
using (var cnx = new OleDbConnection(new AdministradorDAO().conexao)) { var sql = @"insert into usuarios(matricula, nome, senha, nivel, maleta, email) values (@matricula, @nome, @senha, @nivel,…
-
2
votes1
answer163
viewsDoubt filter with Line, ASP NET MVC
I have a question on a filter using Linq, I have a critical object Inside criticism has a ienumerable I need to return a list of criticisms that the status of the last critical move equals 2 But the…
-
2
votes1
answer715
viewsHow to find an item in a comma-separated field?
I have a field in a table with data separated by comma: id_regioes: 1,2,3,4,5,6. When I do the query "SELECT * FROM `tb_operadora` WHERE `id_regioes` = 1", or "= 6" returns ok, but not when it is in…
-
2
votes2
answers153
viewsQueries with various ruby associations on Rails
I want to do in ruby on Rails, this: SELECT * FROM isolateds INNER JOIN genes ON geness.isolated_id = isolateds.id INNER JOIN stats ON stats.gene_id = genes.id INNER JOIN mutations ON…
-
2
votes1
answer455
viewsHow to make a query with different table conditions
TABLE REGISTER A Attributes: Code, name, type TABLE NUMBER B Attributes: Code, number TABLE PERSON C Attributes: Code, gender I need to bring the information name and type of table A with the…
-
2
votes2
answers674
viewsPassing parameter between pages
How to pass parameter between pages in Windows Phone 8 . 1? In the previous version it was made like this: Pag 1: private void Button_Click(object sender, RoutedEventArgs e) { string uri =…
-
2
votes2
answers1171
viewsCan you use the same query and define two different "ORDER BY"?
I use the following passage for a query to the database $cs1 = $pdo->query("SELECT TITULO, URL, IMAGEM , TEMPO FROM post ORDER BY CLIQUES DESC LIMIT 5")->fetchAll(); I would like to explore…
-
2
votes1
answer221
viewsAdd multiple fields from the same table in the same query
I have an "X" table with several fields and one of the fields is "date" and the other is "type". In the same query I need to return the following: - Number of registrations in April - Number of…
-
2
votes1
answer1250
viewsHow to search for similar words or synonyms in Postgresql
I need to get a survey to return similar words I found the phonetic research it can even be used to refine the search I need, but I think this is not ideal. For example, in a database I have several…
-
2
votes1
answer3116
viewsAdd multiple select Count results to MYSQL
I’m wanting to add up all the clients I have on all my bases, so for that I’m doing the following query: SET @total = 0; USE BASE x1; SELECT @total:= @total +COUNT(1) FROM clientes; USE BASE x2;…
-
2
votes1
answer153
viewsUpdate query with select for Procedure
I’m trying to do a query that will enter a previous but I’m not succeeding, the query is like this: UPDATE sca_lotacao AS t0 SET t0.ativo = 0 WHERE ( SELECT * FROM sca_pessoa AS t1 RIGHT JOIN…
-
2
votes1
answer1120
viewsRetrieve data from fields of the same name but from different tables
I have a select that looks for data from three different tables, but has some common fields between these three tables. My question is how to get the data of these fields, which has the common name…
-
2
votes4
answers38774
viewsSequential numbering of query results
I’m not really close to the database, and actually I don’t even need such functionality, but just out of curiosity, it’s possible to create in Runtime, that is, during SELECT, a sequential numbering…
-
2
votes2
answers952
viewsEnum as Hibernate Parameter Namedquery
Is there any way to pass as a parameter in a NamedQuery the value of Enum. public enum TipoConta{ CREDITO("Cartao de Credito"), DEBITO("Cartao de Debito"); private final String descricao;…
-
2
votes2
answers2981
views"Undefined variable" error
I’m trying to run this code but it’s not working. $sql = "SELECT * FROM cliente WHERE id = $id "; $limite = mysql_query("$sql"); while ($sql = mysql_fetch_array($limite)){ $nome = $sql["nome"];…
-
2
votes1
answer943
viewsBring "children" record count along to all table records
How do I count how many "children" such a row have, and at the same time list all the records in the table? I have the table categorias, with the following data: _________________________________ |…
-
2
votes1
answer117
viewsHow to fill null with previous row value?
Looking at the following table, I want to fill the null value with the value of the previous row, which is best to do with mysql?…