Most voted "sql" questions
Structured Query Language (SQL) is a language to query databases. Questions should include examples of table code and structure. This tag refers to the default language, not to be used for questions about the implementation of specific DBMS (such as Mysql, Postgresql, Oracle, MS SQL Server). In this case use the specific DBMS tag. Answers to questions marked with ANSI SQL should use SQL as much as possible.
Learn more…6,771 questions
Sort by count of
-
0
votes1
answer73
viewsRelationship of two MYSQLI tables
I’m trying to link two tables so the result looks like this; Address for test of the query http://sqlfiddle.com/#! 9/d9acad/1 I tried to use the command below; SELECT item_inventarios.sku,…
sqlasked 5 years, 6 months ago Hugo Rutemberg 307 -
0
votes0
answers90
viewsSum all values in a column and group every 2 minutes
I wanted to add up all the values every 2 minutes and group those same values valor tempo 0.3 2019-05-22 01:11:45---> first value 0,3 0.3 2019-05-22 01:12:16-----| 0.3 2019-05-22…
-
0
votes1
answer33
viewsError using Between with codeigniter
How to create a function SELECT ii.sku, ii.cod_setor, ia.setor_ini, ia.setor_fim, sum(ii.quantidade) as quantidades, ia.desc_ambiente, ii.cod_coletor FROM item_inventarios ii inner join…
-
0
votes1
answer23
viewsStore two names in the same column
I’m in doubt about best practice to create a certain table. I have the table "Texts": My problem is with the column "authorship". Because the authorship has 3 options see: If the user selects the…
-
0
votes2
answers136
viewsI can’t get information from my API via android app
I created a web API with the code: <?php header('Content-type: Application/JSON'); include("../Classes/conexao.php"); if($_SESSION['conectado'] == false){ echo json_encode("Sem resposta do…
-
0
votes0
answers30
viewsIf informed parameter does not bring any data in the Stored Procedure (Oracle)
I’m having a problem in the Stored Procedure below, where it only brings the data if the parameter of EmpresaId come blank. If I inform the parameter EmpresaId, does not bring any data. I am a…
-
0
votes2
answers66
viewsInsert a date into the database via jquery+php
I have a datepicker like this <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script…
-
0
votes2
answers283
viewsSQL Firebird search for last names by initial letter
Precise research by the letter initial of the surnames within a column that has full and compound names. Examples: Jean Carlos Luciana Menezes Rezende Roberto Menezes Souza Vero Vinicius Desired…
-
0
votes0
answers46
viewsString INSERT INTO Error with Quotes
I have the INSERT INTO below that shows error in the field where the value is '[/\d/, /\d/, /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/]' INSERT INTO ADVDEV."Mascara"("Guid", "MascaraId", "EmpresaId",…
-
0
votes0
answers32
viewsReturn all results in a grouped query even if the sum is zero or null
I have the following consultation grouped: SELECT SUM(SUC.PESO), EXTRACT(DAY FROM HU.FIM), CASE WHEN (ACO.COLUNA_2 IN ('L','C') AND HU.ESP_MM_UNMET<=3) THEN 'Carb' WHEN (ACO.COLUNA_2 IN ('L','C')…
-
0
votes1
answer58
viewsSQL query does not return even having values
I didn’t mean that Returns SELECT * FROM tbl_temporadas WHERE serie_id = '2' AND serie_slug = 'dois-homens-e-meio' AND temp_audio = 'l' Does not return SELECT * FROM tbl_temporadas WHERE serie_id =…
-
0
votes1
answer265
viewsHow to check if an XML type field is null or empty in SQL SERVER
I need to check the amount of 0, NULL or empty in fields of different types, My difficulty is when it comes to fields of type XML. I tried to include in my logic the function exist(), but I do not…
-
0
votes1
answer81
viewsUpdate with two tables at the same time
I’m doing an update to edit window and it’s not giving error, but it’s only working the address part, the beekeeper information part is not updating Beekeeper table <?php session_start();…
-
0
votes0
answers22
viewsIsolation Level - SQL SERVER
Opa I have an OLAP environment where there are reports that consume information from it. But lately I have picked up some LOCKS in the environment for some old procs are not "properly" elaborated. I…
-
0
votes0
answers73
viewsError in Mysql sub-query in Workbench
Good morning! My code SQL is making the following mistake: Error Code: 1242. Subquery Returns more than 1 Row 0,000 sec The code is as follows:: SELECT DATE_FORMAT(FROM_UNIXTIME(data), '%Y') AS ano,…
-
0
votes0
answers805
viewsorg.postgresql.util.Psqlexception: ERROR: Operator does not exist: bigint = bytea
I have a method that retrieves all paths from the appendices of a ledger, so the appendices can be printed. They are listed in a p:datatable within a dialog, but when opening the screen so that I…
-
0
votes1
answer26
viewsSQL Transform XML attributes into columns
I have the following code: IF OBJECT_ID('dbo.tabTeste') IS NOT NULL DROP TABLE dbo.tabTeste GO CREATE TABLE dbo.tabTeste ( id_tab INT IDENTITY PRIMARY KEY, field1_tab VARCHAR(255), paramsxml_tab…
-
0
votes1
answer18
viewsPerform an external-based query in the Zend Framework
Model public function excluirFiliadosNaoEnviados($base) { $sql = "SELECT FROM " . $base . ".debito_automatico"; $acao = $this->conexao->prepare($sql); if($acao->execute()){ return true;…
-
0
votes1
answer157
viewsMysql, SELECT according to the specialisation of the generic entity occurrence
In my database I have a generic entity "user", such entity is specialized in two other "store" and "service_provider", this specialization has total and exclusive characteristic, so that, an…
-
0
votes1
answer321
viewsDROP permission of tables in SQL Server databases
When executing the (T-SQL) DROP command below in SQL server the following message is displayed: Cannot drop the table '[dbo]. [TABLE]', because it does not exist or you do not have permission.…
-
0
votes1
answer63
viewsHow to convert a function to view
Good afternoon, I have the following function: if object_id('dbo.batidas', 'TF') is null begin exec('create function dbo.batidas() returns @retorno table(T int) as begin return end'); end; go alter…
-
0
votes2
answers83
views -
0
votes1
answer135
viewsCOUNT and SUM with 3 tables
I’m making an IT management system. I have 3 tables: Computers, offices, office_keys Example: offices ______________________________________ id | 1 version | Home & Business 2016 office_keys…
-
0
votes2
answers299
viewsHow to use a variable to delete with like? SQL Server
I’m having trouble developing the T-SQL below: DECLARE @NOME_FILIAL VARCHAR(25); DECLARE @DATA_AJUSTE DATETIME; SET @NOME_FILIAL = (SELECT FILIAL FROM FILIAIS WHERE COD_FILIAL='125518'); SET…
-
0
votes2
answers75
viewsList only if the other table does not have a dismissal
Good afternoon. I need to make a list of employees per year. For example. Active employees 2018, However I’m having problems, because in 2019 some were fired there not list the same, and use the…
-
0
votes0
answers144
viewsHow to save data from a column and then overwrite it again? SQL Server
I need to save data from a table to a database command and return that data to the same table after a while... I thought I’d do something like this: DECLARE @NOME_FILIAL VARCHAR(25); DECLARE…
-
0
votes2
answers46
viewsInsert records that only exist in the source table with MERGE
I created the following script that only inserts records that do not exist in the table teste_tb_planos_acoes, put some conditions: If the column value designacao exists in the table…
-
0
votes1
answer36
views"lazily" error in java web application
Good afternoon, I am developing a library web system, however, on the book page I can usually persist with the data, but when I try to edit them, the error occurs: "HTTP Status 500 - failed to…
-
0
votes0
answers49
viewsHow to concatenate results from an SQL
I have two tables: Produtos, Eventos and Productsprovents(coming from the many ratio for many of the tables Products and Events): I performed the following SQL to get the event data and products…
-
0
votes1
answer510
views -
0
votes1
answer118
viewsAttributeerror- Sqlalchemy Flask
'str' Object has no attribute 'contains' I am trying to create a query using Flask-Sqlalchemy Flask should return me a list of books according to the user’s search. It selects 4 search options and…
-
0
votes1
answer27
viewsHow to get around an sql situation where I don’t have all the information
I’m using the php programming language where: I have the following method of a class: public function executaquery($s, $con) { $query = ''; $total = 0; $s = str_replace(".", ";", $s); $s =…
-
0
votes0
answers37
viewsReading SQL data without NOLOCK
I have a Stored Procedure (SQL Server) that is accessed by several applications concurrently at intervals of less than 1 minute. It was built using NOLOCK in its accesses, most likely to gain in…
-
0
votes2
answers972
viewsHow to Use an UPDATE within IF ELSE SQL Server
I’m trying to verify if a column exists within a certain table. When checking if it exists, I want to update the column with the value 1, if not, create and update. However, every time I run the…
-
0
votes1
answer238
viewsQuery in two Oracle tables
How do I query two tables at once? I have two table structures as follows. TGFCAB ___________________ |NUNOTA| DTMOV | ------------------| | 1 |01/06/2019| | 2 |02/06/2019| | 3 |03/06/2019| and…
-
0
votes1
answer387
viewsBank Consuming all memory
Good day I am with a problem , users of a given system are having problems when consulting a name in the system "a simple search" I joined the bank and noticed that in sql there are several banks…
-
0
votes1
answer149
viewsHow to insert xml tag within a sql server table
I am trying to insert an XML tag that is allocated within a field in an SQL table (SQL SERVER) I am currently trying so but am unsuccessful: update UserData set tp_ColumnSet.modify('insert…
sql xml sql-update sql-insert sql-server-2012asked 5 years, 4 months ago Guilherme G. Bitencourt 11 -
0
votes1
answer132
viewsTable Link - Mysql
I’m setting up a system for the user to register/delete/edit/view courses of the school where I work, I set up all the tables but when I will do a inner join in one of the tables does not give me…
-
0
votes1
answer45
viewsCount SQL repeats with INTERSECT and COUNT
I have an SQL table with hundreds of data, and I would like to introduce an array, the same be compared with this table and it is informed how many repetitions occurred. (Table --> EVENT | DADOS1…
-
0
votes1
answer330
viewsFatal error SQLSTATE[42000]
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for…
-
0
votes2
answers189
viewsHow to locate information by considering a range (range of numbers)
In the company where I work we are automating the process of calculating variable remuneration, and for this we are transposing all the logic that was in the EXCEL to the database. However, I’m…
-
0
votes2
answers493
viewsCount number of rows of different tables doing LEFT JOIN using the Count() function
I need to count the number of tables records cliques and curtidas and show these numbers to the media type Video table tipo_midia and the specific media, that is, the video that the person liked or…
-
0
votes0
answers81
viewsConstraint Fk Composite
Hello, I am creating a Foreign key Constraint composed like this: alter table "Tabela1" add constraint constraint_fk foreign key ("Guid","Tabela2Id") references "Tabela2" ("Guid","Tabela2Id") When I…
-
0
votes2
answers118
viewsBasic SQL (Join and Where)
Good night, I’m trying to solve a problem which is this:: Tables: editoras (cod int primary key, nome varchar (50)); autores (cod int primary key, nome varchar (50)); livros (isbn char (13), titulo…
-
0
votes1
answer427
viewsSeparate results from an SQL query by date
I am creating an SQL query that will be used in a system/report and came across the following problem. It has two results, one that displays the total time between the days searched and the other…
-
0
votes2
answers46
viewsmysql query that groups the distances travelled each day
Hello, I started a query from a mysql database where the distance of each commute of a driver is saved along with the time: DATE_FORMAT(l.dateGenerated,'%d/%m/%Y %H:%i') AS Day , d.name AS…
-
0
votes2
answers309
viewsHow can I only enter a certain amount of records into sql server?
I have a table called Hoteis which is related to another helper table Hoteis_Fotos, as its name suggests this table will save the photos of a particular hotel. As you may have understood, each hotel…
-
0
votes1
answer56
viewsSelect after select result
I am trying to select in a table to display a list of activities. And second select on each of the first select lines to count how many are in each status, but I’m having syntax error, which I’m…
-
0
votes1
answer156
viewsReportbuilder report sorting error
In a report built in Delphi7 Reportbuilder I have vendor information in a group header and vendor items in a Detail tab just below. The problem is that it is not possible to sort items (Detail)…
-
0
votes2
answers1109
viewsInsert error: There are more Columns in the Insert statement than values specified in the values clause
When I give an input searching data from another table, this error is returned, which may be wrong with the query ? INSERT INTO dbo.CRMRAT (IDCRMRAT, CODCOLIGADA, STATUS, TIPO, IDCRMCLIENTE,…