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
-
3
votes1
answer83
viewsHow to perform an arithmetic operation without ordering it in GROUP BY
Having the following SELECT consulting a dynamic table from a subselect, I get the result of the query correctly but with records divided in the following example: cod_representante | ... |…
-
3
votes1
answer852
viewsHow to change null field to not return anything?
In a query has many fields not being filled in, would like to exchange the null that is being printed so that nothing appears in the print.
-
3
votes1
answer49
viewsJava - SQL Error Updating All Users
Good morning, I’m having the following problem my updateOur SQL is updating all how I do so that it just updates the User who accessed? public class Acessar { public static Connection con =…
-
3
votes3
answers325
viewsData types in SQL Server 2012 and HTML forms with PHP: date and monetary values
How can I put a mask in an HTML form, in the date and monetary value fields, then send this data to the database without having to convert the strings into types date and money? Explain: I have a…
-
3
votes2
answers606
viewsSave image array to different columns
Good night. I would like to count on your help in solving a problem that has been grinding my molecule for a few days and I have not yet been able to find a solution. I have the following code to…
-
3
votes1
answer9356
viewsQuery data in two tables and add one of the columns
I have two tables need to make a SELECT in both at the same time, basically it will work like this: Note that the result returns the column nome of Tabela A and sum of column media where the ids are…
-
3
votes1
answer156
viewsHow to update sql in visual studio 2015
I am in an ASP MVC project. When I try to log in or use the database the following error occurs: The database 'aspnet-Nerdchest-20160621052548' cannot be opened because it is version 852. This…
-
3
votes1
answer1045
viewsRemove old Mysql records automatically
I have a table that stores logs from a system. I want some method to automatically delete logs older than 60 days. It has how to do this?
-
3
votes1
answer398
viewsRelationship 0.. 1 in practice
Having the following tables: request address table Orders can be made at the pizzeria, that is, for a table. It can be a delivery(address) or it can be a request for travel, where it does not belong…
-
3
votes4
answers15818
viewsAdd and Subtract value from same SQL column
I have a table with the following data: +---------------------------+ | Cod_Art | Armazem | Quant | +---------------------------+ | 11430001 | 1 | 0 | | 11430001 | 2 | 3 | | 11430001 | 3 | 0 | |…
-
3
votes1
answer2071
viewsMaking a select in all tables of a schema
It is possible to search for a certain value in columns of other tables? Example: I have a number: 23028908 I want to search in my bank, all columns that have this value. Is that possible? How it…
-
3
votes2
answers78
viewsDifficulty to query in Mysql
First I’m starting now to mess with mysql I’m very lay in the subject yet I have a table called products_search_items and this table has 2 columns a product_i" and the search_item_id I needed to…
-
3
votes2
answers3629
viewsError trying to remove a temporary table
I have a service where I load data from an ERP into a DW. The source of the data is SQL Server 2008 R2 10.50.1600.1 and the target server MS SQL Server 2008 10.0.5512.0 SP3. The service performs a…
-
3
votes2
answers1359
viewsSpecified conversion is not valid in Executescalar
The specified conversion error is not valid happens in the code: if (command.ExecuteScalar() == DBNull.Value) { resultados[j2][i2] = 0; } else { resultados[j2][i2] =…
-
3
votes2
answers331
viewsI cannot enter user-defined values in Sqlite
I have a problem where I can not add anything in the table and always appears the error: sqlite3.Interfaceerror: Error Binding Parameter 0 - probably Unsupported type. The code I’m trying to add…
-
3
votes1
answer1978
viewsHow to add multiple phones to the same form dynamically?
I’m studying PHP and SQL and I am building a system so that my mother can better manage all customers using the transport service that she provides. I built a simple registration page with the…
-
3
votes2
answers1286
viewsMultiply the amount of elements from two different tables
I have two tables: pessoas and carros. I would like to take the number of elements of both tables, and multiply them.
-
3
votes1
answer481
viewsSelect Distinct returns repeated data when using Row_number
I’m trying to make pagination with SQLServer 2008 as follows: WITH CTEResults AS ( SELECT DISTINCT SolicitacaoServico.AutoId AS Id_Solicitacao, Pessoa.Nome AS Nome, Beneficiario.Codigo AS…
-
3
votes2
answers485
views -
3
votes2
answers654
viewsHow to list the data of an SQL query grouped in order of data presentation
I wonder if there is a way to group records in the order in which the survey is presented. Let’s say I have a table of two fields Location (mapped place), Time (Date and Time). Place was filled in…
-
3
votes2
answers957
viewsHow to compare set of numbers with other set?
How to mount query to compare if a set A of numbers is equal to another, of B, with the same numbers of set A, and so on. Example: Table data id conjunto numero ordem 1 1 1 1 2 1 12 2 3 1 4 3 4 1 6…
-
3
votes1
answer5600
viewsHow to list the highest salary among all employee functions?
Guys, I want to know how do I list only the function that has the highest salary and not the highest salaries of all functions, does anyone give me a light? Go on like I’m doing: select max(Salario)…
-
3
votes2
answers2382
viewsQuery with dynamic spring data column
I need to perform a select using the spring data @Query, but I need to pass the column name by parameter Example: @Query("SELECT g FROM Grupo g where g.? = ?") Page<Grupo> findTeste(String…
-
3
votes1
answer253
viewsDoubt mysql and Left Join
I have the SQL below, which returns data that I will fill in some inputs of a form. The problem is that I have 20 items (pieces) in this table, but it may be empty because the user can fill any…
-
3
votes2
answers2315
viewsNumeric Overflow with Numeric(18,7) in Firebird
I need an accuracy of 7 houses in a given split calculation, but when the divider is very small, it generates an extensive number. When I try to give the cast, it gives Numeric overflow, even the…
-
3
votes3
answers944
viewsReturn the Id of table 1 and insert in table 2 in the same code
Talk guys, next, to with 2 tables (Group1 and Group2), there I have a form that has several fields that will be inserted at the same time in these 2 tables. But I need to insert in the table Group2…
-
3
votes2
answers109
viewsHow to show latest date data?
I have a Tabela1: ID Auto_increment; varchar; date; I would like to show only the data with the latest date. How do I?
-
3
votes1
answer224
viewsHow to show result between 3 tables?
I have these three tables; table_1 |---------------------| | ID1 | name | |---------------------| | 1 | 'xxxxx' | | 2 | 'xxxxxx' | | 3 | 'xxxxxxxx' | | 4 | 'xxxxxx' | | 5 | 'xxxxxx' |…
-
3
votes1
answer7311
viewsHow to select in the database involving Foreign key and Primary key?
I have a problem, I have two tables that are related from the foreign key and the primary key like this: CREATE TABLE IF NOT EXISTS cargo( id INT AUTO_INCREMENT NOT NULL, nome_cargo varchar(50) not…
-
3
votes1
answer754
viewsWhat is the difference between the various JOIN types of SQL?
In SQL there are several types of JOIN, what is the difference between INNER JOIN, LEFT JOIN, CROSS JOIN, RIGHT JOIN and FULL JOIN?…
-
3
votes1
answer238
viewsHow to turn this query into a JPQL?
I have the following query in the postgres database: select * from trabalha_projeto tp inner join Empregado e on e.matricula = tp.empregado how it turns it into a JPQL query? I’m having a hard time…
-
3
votes2
answers1309
viewsWhy put COMMIT at the end of the script using the Firebird database
Why in the Firebird database everything I do, including creating tables is necessary at the end of the script to give a command COMMIT?
-
3
votes2
answers1269
viewsSave without accents and uppercase SQL Server
I’m creating a database, where I need to save all fields in uppercase. Searching the internet, I found the following collate that would work, but it still keeps saving with accents and in upper and…
-
3
votes2
answers140
viewsIt is possible to save multiple values in a single database field
I declared the field in the database like this: descricao VARCHAR2(5)not null, It is possible, for example, to save 1,2,3,4 at once (a single record) in the field descricao, where each of these…
-
3
votes1
answer1898
viewsHow to return only records without matching in a JOIN?
I have a question regarding the use of JOIN in SQL in this case: I have a table produtos and a table destaques containing the id product. I need to make a query that returns only the records that…
-
3
votes1
answer345
viewsSQL Like without considering the order of the parameters
I need to make a comparison between two tables to find out if the address of table A is present in table B. Example: Table A has a record with the ENDERECO field with the value "RUA FULANO DE TAL 67…
-
3
votes2
answers313
viewsDiscovering the binary value in SQL Server
Is there a function in SQL Server that converts an integer into binary ? Example: SELECT Funcao_Binario(2) -> Saida : 0010 SELECT Funcao_Binario(4) -> Saída : 0100 SELECT Funcao_Binario(5)…
-
3
votes1
answer52
viewsReplace in update, change extension in filenames
I have a table with images, images, in which one of these columns (file_name) has names of pictures, some jpg others png, what I need is to change, to make UPDATE all to the extension png, that is,…
-
3
votes2
answers2509
viewsHow to group multiple records into a single row
I have a query where I need the values of other related tables to be grouped in a single column. For this I use a for, however, the lines come duplicated. I would need the result to bring only the…
-
3
votes2
answers17826
viewsHow to select in date format?
How do I select using dates on SQL server 2008? When I do a search with this select: select * from NOME_TABELA where DATA_FISCAL between '2016-05-01' and '2016-05-11' The result is 12 records…
-
3
votes2
answers289
viewsReplace table content with table content?
My case is this:: I have two tables TAB1 and TAB2; the two tables have the same structure: (id, name, surname). I would like to replace the content of TAB1 to the TAB2. Everything that exists in…
-
3
votes1
answer269
viewsPIVOT - SELECT reversing row and column
I have a table like this: codigo ano quant 100 2014 15 100 2015 13 100 2016 20 101 2015 15 102 2016 22 102 2014 05 I want to create a query that lists me the code like this: codigo 2014 2015 2016…
-
3
votes2
answers2443
viewsHow to get data from the previous line in SQL?
How to create a column with the value of the previous row of another column? Follow example, I have the column time and I want to create the column time_lag: Tabela inicial: id | title | time |…
sqlasked 8 years ago Henrique Pizarro 659 -
3
votes2
answers210
viewsSum if in Mysql Workbench
I have a database in Mysql. No_Pedido|Valor|Cortesia 123|1000|Sim 123|500|Nao 124|200|Nao 124|500|Nao I need to make a select that returns the sum of the value per request that is not courtesy,…
-
3
votes2
answers105
viewsQuery bringing all records, and filter the repeated
Have table mov_pallet(some records): movpallet rua altura posicao hora produto data pallet 1.424.959 1 C 4 09:30:07 18.342 02.05.2016 456.074 1.424.960 1 C 4 09:27:07 18.399 05.05.2016 456.182…
-
3
votes3
answers2181
views -
3
votes1
answer368
viewsFormat date in INSERT and UPDATE Mysql PHP
Well I have a registration Gride with date, only I have to use a Mask of Jquery: $(document).ready(function(){ $('.date').mask('00.00.0000'); }); But when I do an INSERT, for example, the date…
-
3
votes2
answers187
viewsChecks if in a value group there is a value x mysql
I have a select that returns some data from the database, but I need this select to return the values only when in a group of values, there is the value x SELECT pessoas.id AS ID, pessoas.nom_pessoa…
-
3
votes1
answer193
viewsShow warning message without exception
I would like to display an alert message to the user without causing exception in the Database. I am using SQL Server. So I cannot use RAISERROR, nor PRINT, because it is not shown to the user.…
-
3
votes1
answer49
viewsPresentation of the php query
I need you to help me create a php function that lists multiple tables in a row with multiple columns, depending on the amount of records in the database and the spacing of the tables defined by…