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
-
2
votes1
answer78
viewsGet the largest elements of an SQL column
I have 3 tables and I have the following question to solve: "Get the "name" with higher "Perce" related to "num2". Enter "num2" through "Name2" -- A (name,Num2, local) insert into A values…
-
2
votes2
answers5191
viewsHTML and SQL connection
I’m designing a database where I have a table with calculated data indices from other tables. I am also designing an HTML Dashboard to expose these indexes. My database is stored on a Mysql server.…
-
2
votes1
answer50
viewsSearch Records with Latest Date Using Condition
I have the following appointment: SELECT fm.FIELDCODE, fm.BLOCK_CODE, bl.BLOCK_DESC, cat.CATEGORY_CODE, cat.CATEGORY_ABBREV, fm.FIELD_AREA, fm.PLANTATION_DATE, fm.HARVEST_END_DATE FROM FM_BLOCK bl,…
-
2
votes2
answers82
viewsJoin bringing wrong value
I have two tables Enterprise: id_empresa id_usuario vl_honorario dt_honorario id_honorario 86 1 200 2017-01-04 7 86 1 600 2016-12-01 6 86 1 500 2016-11-01 5 86 212 300 2016-12-01 5 Honorary:…
-
2
votes1
answer153
viewsHow does the process of accessing a database work?
I started studying databases and to access a certain database with JDBC a driver is required for each DBMS (Mysql, SQL Server, Oracle), and the access is done on disk, but how is this process done?…
-
2
votes1
answer139
viewsID of out-of-order tables
I have a table with 9 records, my identities are in order from 1 to 9, when I enter a new record in the table automatically a new ID is set, but it is set with the value 30 instead of the next…
-
2
votes1
answer575
viewsProblem when doing Table Insert in Postgresql
When I’m gonna make a INSERT: INSERT INTO categoria (cat_descricao,cat_status) VALUES ('não' ,'1' ) passing some element with accentuation parameter the following error occurs ERROR: 22021: invalid…
-
2
votes2
answers521
viewsCheck duplicate items and update a column in all but one
I have a table of products that bring information from an XML, and another table in the system that basically receives these products after approval (we have an interface to define what enters or…
-
2
votes1
answer33
viewsLogin transaction log MSSQL 2012
I need a help, I have to provide a login on MSSQL ERP company and my superior need to monitor transactions of type INSERT, DELETE and UPDATE that are made by them, in case the scripts that were…
-
2
votes1
answer155
viewsHow to work with IN instruction in PHP + PDO?
I’m trying to build a dynamic SQL but I’m getting beat up for not understanding how to work with the IN statement in PDO Example: $SQL = "select * from tabela where (campo in(:valor))"; $Query =…
-
2
votes1
answer172
viewsHow to delete lines from a datagridview
I am developing a program in C# and would like to know how I can block/delete an sql line in datagridview. The line I wanted to delete/block is the last one selected in the print, I wanted to know…
-
2
votes2
answers221
viewsError in CRUD UPDATE command - java.sql.Sqlexception: No value specified for Parameter 8
I am building a Java system with connection to Mysql database, but I stopped at a certain point because I can’t locate the error. My update method happens an error in Junit, but I can’t figure out…
-
2
votes3
answers883
viewsValidate whether INSERT was successfully executed or not (JTDS)
I would like to know a form of validation to know if the Insert was successfully executed, I have no idea how to do this because the execute() method does not return anything!!! Connection…
-
2
votes1
answer105
viewsAdding a Character to a column value
I would like to know whether it is possible to include a character set at the end of a column data. For example: 'Coluna 1- Quantidade |10000 |20000 |15000 |20000 I want to extract a query where I…
-
2
votes1
answer6162
viewsTraverse row by row of a table
I have a temporary table that I fill with the result of a particular query. I need to go through the data of this temporary table, row by row, and take certain fields and insert them into another…
-
2
votes1
answer434
viewsCheck Connection to bank and validate to user
I would like to know the following: I am trying to make an application that makes several connections to the database. I always wanted to check the connections and if the connection is not available…
-
2
votes1
answer291
viewsInsert error with FK
I have two tables, Client and Plan, which have the relationship 1:1. I have 3 plans registered in the database with their respective data. But when trying to insert a Customer that has a Foreing Key…
-
2
votes2
answers5477
viewsHow to remove the first character from a string in a Query
In the Postgresql 9.2 I have a column with the following information: A101 B12 C3 I need one command to select and another to update this column by removing the first character thus: 101 12 3 I…
-
2
votes3
answers38
viewsSelect in each response different values with Mysql Database
I would like to know how to select the number of records from a table where only values greater than 6 are selected, but each result is different, with the Mysql database, for example: Tabela Notas…
-
2
votes2
answers5648
viewsHow to change the name of a column in a select in the database?
I am making a database for a college activity and was asked to display the table by changing the name of attributes(columns) to "Nome do Cliente" and "Endereco do Cliente". How can I do that?…
-
2
votes1
answer148
viewsHow to use foreign key to create a record in another table
I have two tables users and users_info, would like to use foreign key, for when I create a record in the table users, create a record with the empty fields in the table users_info, only with the…
-
2
votes0
answers95
viewsHow to perform selects through Workbench Diagrams?
I am migrating to Mysql Workbench and need to perform a relationship between tables SELECT... INNER JOIN... LEFT JOIN..., but I wanted to accomplish through the diagram of Diagrams. How can I…
-
2
votes1
answer208
viewsChanging a data type across the schema in the oracle
Good afternoon ! I need to alter some kind of data from all my schema, I have the varchar2 size 80, and I’d like to change it to 100, but this all at once... it’s possible ?
-
2
votes3
answers111
viewsPrevent data from appearing in MYSQL search
I have a table composed by the following columns, ID, Produto, Compra, Venda and Resultado. I know the syntax to select the values I want, Example: Select * From tabela_exemplo where Produto =…
-
2
votes1
answer421
viewsSELECT Multiple Date Range in Mysql
Guys, I have a problem extracting dates on a range of trainings. What I need is the following if a training had its beginning on 01/01/2017 and its completion on 03/03/2017 raise should return in…
-
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
answers71
views -
2
votes1
answer1751
viewsImprove slow query performance on MS SQL SERVER
The indexes are incorrect? I’m having trouble optimizing a consultation. I had done another question for a simpler case that solved, but for this case I’m not getting a better result. The following…
-
2
votes2
answers1177
viewsConsult current month birthday in SQL
I need to do a birthday consultation this month. But I would like it to be automatic, and I don’t need to type the month. Below is the example I did, typing the month. Note: my field is dt_nasc…
sqlasked 7 years, 2 months ago Danilo F R Oliveira 21 -
2
votes1
answer78
viewsFunction to read file via ODBC
Hello, it must be a very simple problem, but I’ve searched a lot and I couldn’t find a solution to my question. My setting is: R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit)…
-
2
votes0
answers81
viewsLoading Jtable and processor gets high in process
I’m making a sisteminha and in it has a JTable and I need to loader my data, I’ve been analyzing by task manager that when this table load function is called, it greatly increases the processor…
-
2
votes0
answers182
viewsEngine with lower RAM consumption than Innodb/Xtradb in Mariadb?
Innodb allows you to make several INSERT and also UPDATE without creating LOCKING, while in Myisam it is not possible to make several INSERT at the same time and to make matters worse Myisam does…
-
2
votes1
answer67
viewsRepetitions and combinations of values
I have a table (corner) with 5 fields, each field can have the value from 1 to 80. I wonder if it is possible in SQL or only in Delphi, to catch the dukes (combinations of 2 numbers) between 1 and…
-
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
answer694
viewsMult Mapping Dapper
I am having problems with Mult Mapping of Dapper, when I try to execute the following query is not mapping the object ids select is this: var sql = @" SELECT ofi.id_oficina, ofi.codigo, p.id_pedido,…
-
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
votes4
answers1225
viewsHow do I write a store that uses current and previous line values?
I have the following table, # id # dataTmp # referencia #nProduz#nStock # id2 #necessi# # 115237 # 31-01-2017 # VL03280103 # 0 # 0 # 6 # 0 # # 115238 # 01-02-2017 # VL03280103 # 0 # 0 # 7 # 0 # #…
-
2
votes4
answers1358
viewsHow to return the date and time closest to that informed by the user
I have a table with a list of places a truck has passed with the date/time of its entry and exit +----+------------------+-----------+---------------+ | ID | DATA E HORA | LOCAL | ENTRADA/SAIDA |…
-
2
votes1
answer131
viewsReturn only part of the SQL field in the query
I wanted to return in the query only the values that are between parentheses in the table field. SELECT F2 FROM [dbo].[Vestcasa_Ranking_Produtos_Custo_] F2 Airtom..(635) paulo victo r.. (234)…
-
2
votes4
answers129
viewsBuild database
I need to build a database with 200 rows and 4 columns (with the 4 variables I idealized). I devised a study to estimate the presence of snakes in a given city, I have no data. I thought that the…
-
2
votes2
answers2673
viewsRemove tab(tab) from sweeping
Good afternoon, you guys! I’m trying in every way, but I can’t get a tab at the end of a varchar in Firebird. Someone knows how to do? From now on, thank you. Editing to get more specific: Ex.:…
-
2
votes2
answers467
viewsDuplicate Select Postgresql output
I have a record that is a receipt, and in select, I want the line to come duplicated. Ex: Select * from recibos where codigo =1; Upshot: codigo|cliente|valor|emitente|data 1 Fulano 10 Ciclano…
-
2
votes1
answer2174
viewsHow to make an insert with conditions in SQL?
I am trying to make an Insert, a column of which depends on a result INSERT INTO TABELA (ID, (CASE 'opcao1' WHEN 'opcao1' THEN "campo1" WHEN 'opcao2' THEN "campo2" ELSE campo3 END)) VALUES…
-
2
votes1
answer345
viewsHow to join records from a table distributed in multiple . sqlite files?
I have several files with extension .sqlite, containing every 1 at least 1000 records thus totaling about 4,000 records. See how they are distributed: vihicles1.sqlite vihicles2.sqlite…
-
2
votes2
answers502
viewsSQL with 2 of multiple conditions
I’m having trouble making a Select that meets 2 or 3 conditions of several selected, for example: Conditions: - Cidade Tal (São Paulo) - Nome Tal (João) - Sexo (Masculino) - Fumante (Não) - Carro…
-
2
votes3
answers554
viewsUsing the Case When Then command with Entity Framework
I have the following structure corresponding to a table in my database: Cat_Codigo, Cat_Descricao, Cat_Observacao, Cat_Status Where the Cat_Status is defined by 0 or 1, with 0 -> Deactivative and…
-
2
votes2
answers1290
viewsHow to check Null in a select @Local_variable
To set a default value for a local variable, if the select that should "set" it returns NULL? For example: DECLARE @Minha_Var VARCHAR(70) SELECT @Minha_Var = Nome FROM CLIENTES WHERE Id = 10 This…
-
2
votes0
answers58
viewsWhat is the best architecture? Mysql multi BD or single?
We are currently working with a web software that is going to the market with great acceptance. It receives many partner interfaces and generates a lot of content for each table. In the past we…
-
2
votes1
answer168
views -
2
votes4
answers4228
viewsHow to perform query with some null values?
The SQL below returns the values correctly only if the field data_emissao be as nonzero in my BD table (independent if the parameter cliente was passed or not), but I wish to return the values where…