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
answer83
viewsConsult with INNER JOIN and choose the loop reference
Guys, I’m looking at two tables with INNER JOIN thus: if (! $db->Query("select * from cad_produto inner join cad_variacoes on cad_variacoes.id_produto = cad_produto.id")) $db->Kill(); while (!…
-
2
votes1
answer187
viewsINNER JOIN performance in SQL
Hello, would anyone know me if there is any significant difference in performance in the two ways of doing INNER JOIN below? Way 1: SELECT column_name(s) FROM table1 INNER JOIN table2 ON…
-
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
votes2
answers507
viewsmysql errors being displayed in French
All errors I receive regarding the phpmyadmin database are in Frances. However, the panel is in en, only query errors -a select for example- are displayed in French. I use the WAMP. EX: Aucune base…
-
2
votes1
answer1061
views -
2
votes2
answers2263
viewsHow to generate an extract per month in the database?
I have to generate a statement in the database that is similar to the bank statement and present the cumulative balance. I have the following columns Data, Debito, Crédito. Data entry is daily but…
-
2
votes2
answers130
viewsHow to insert 200 new records?
I need to insert new data into a table, but there are many. I did so: insert into pessoafisica (coluna1, coluna2, coluna 30) select (dado1 dado2 dado30) But there are many, can not do 1 by 1.…
-
2
votes2
answers88
viewsDoubt LEFT JOIN SQL
I need to do a query, where I inform a person code and sql returns me all the people who are within that group that is the person to whom I typed the code. Example: I enter code '1', The code refers…
sqlasked 9 years, 2 months ago Renan Rodrigues 3,709 -
2
votes1
answer63
viewsremove sql zeros
I have a field EUW010598260, and needed you to stay EUW1598260 I need to remove a specific field SQL: SELECT 'EUW' + substring(campo,patindex('%[^EUW0 ]%',campo + ' ') ,len(campo)) AS campo1 ,campo2…
sqlasked 8 years, 10 months ago usersantos 765 -
2
votes1
answer2582
viewsHow to find the foreign from one table to another by Oracle?
When we are running SQL statements and we need to navigate between tables it is simple when we know the database modeling to apply JOIN and GROUP BY, but when we do not know, what to do? It is…
-
2
votes1
answer110
viewsModel comments
I’m creating a comment structure similar to Mercadolivre, how do I make the modeling contemplate and ensure that: NOTE: I’m calling comments question and answer since this is basically how the Free…
-
2
votes1
answer1968
viewsViewing Query History in Sql Server Management Studio
I am trying to recover queries I performed in Sql Server Management Studio 2014, I know there is a simple history functionality in Heidi Sql, I wonder if in Sql Server Management Studio 2014 there…
-
2
votes2
answers522
views -
2
votes2
answers10301
viewsHow to give a SELECT in multiple databases at once?
I have several databases on my server and I need to perform a query to return some information from a table that exists in all these other databases. How can I make a SELECT on several bases at the…
-
2
votes1
answer673
viewsRange of dates VARCHAR/DATE
I have a date field (type VARCHAR) in my table, and recently I needed to search the database with date range. And for that I used the operator Between, getting something like: BETWEEN 15/08/2015 AND…
-
2
votes2
answers156
viewsError: Cannot find data type long
I am trying to create a precedent in SQL Server 2012, but it is giving the following error in signing it. Mensagem 2715, Nível 16, Estado 3, Procedimento MINHAPROCEDURE, Linha 6 Column, parameter,…
-
2
votes1
answer1432
viewsReturn ajax function with result of an sql search
I am doing a section on my website, in which there is a field select. When I select something in that select, i want to conduct a BD search by returning the information about that item selected to…
-
2
votes1
answer70
viewsSelect checking a condition
I need to make a select where a condition is checked. Ex: If the value of a given field is < 0 assign the sum of that field to column "PerdaGerada" otherwise assign the column "LucroGerado".…
-
2
votes2
answers64
views1054 - Unknow colunm in on clause
what’s wrong with this consultation? SELECT clientes.idClientes, clientes.nome, clientes.bloqueado, planosclientes.idPlanos, planos.nome, enderecos.bairro, enderecos.cidade FROM planosclientes INNER…
-
2
votes1
answer114
viewsXML for Database Columns
I have a table that stores an XML in one of its columns, but I need to make a select by placing each XML item in a column. The problem is that I don’t want to create another table, I want something,…
-
2
votes1
answer3358
viewsQuery in relationship table N:N
How to display all projects that have a specific advisor? The relationship between Supervisor and Project is N:N, therefore contains the table Projeto_has_Orientador as relationship table. Tables:…
-
2
votes1
answer20445
viewsHow to open a. fdb file?
I need to open a database file (.fdb), but I don’t know how. What should I do to open this file? In it there is a list I want to pass to Excel.
-
2
votes1
answer900
viewsHow to traverse lines of a SELECT in a STORED PROCEDURE in SQL Server?
Other than with the use of CURSOR and WHILE in the SQL Server, what other ways it would be possible to traverse the result lines of a SELECT in a STORED PROCEDURE?…
-
2
votes2
answers2254
viewsIs it possible to know where an sql execution originated in SQL SERVER?
There is a situation that I believe will be of great importance to me, which is to know the origin of an sql command in SQL SERVER. Suppose that accidentally a user has executed any command. Then I…
-
2
votes1
answer99
viewsXML for temporary table records
Last week I I asked Here on how to place each XML tag in a database column. Now I came across a situation close to that but with a plus, my XML comes from the database, and sometimes will come not…
-
2
votes3
answers329
views -
2
votes1
answer469
viewsWhat are the differences between Stored Procedures and Functions within Sql Server?
This is a question in a certain academic way, but I have come up with the question. What are the differences between one and the other? What I should consider to choose each case in certain…
-
2
votes1
answer562
viewsSetting up an SQL for School Report?
I am trying to mount an SQL to display the results of a School Report Card. In the table of notes I have the data as follows. Table Notes MATERIA | NOTA | PERIODO PORTUGUES | 5.0 | 1Bim PORTUGUES |…
-
2
votes1
answer9153
viewsSQL Convert minutes to minutes:minutes:seconds
How to convert a value in minutes in oracle to the time:minutes:seconds format?
-
2
votes4
answers10668
viewsHow to create a Boolean column on Oracle?
As far as I know, Oracle does not provide a valueType of the kind Boolean. I am working a short time with Oracle and would like to know what is the best solution to "simulate" a true/false value in…
-
2
votes1
answer185
viewsCan Sql Server Management Studio handle any database?
I am asking this question because I find this DBMS simply fantastic, so I would like to use it with another database (not because I want to, but because most of the databases I have are in Mysql).…
-
2
votes1
answer105
viewsResult update from another table
I have the following SQL: SELECT id_grade ,MAX(data_lancamento) FROM faturamento_produtos WHERE data_lancamento < '01-01-2010' GROUP BY id_grade Where it only searches for what was released…
-
2
votes1
answer924
viewsDelete all objects from a schema
I have a database on oracle where I need delete all objects of a particular Schema, I cannot exclude the Schema, because the validation of the system is based on an algorithm that takes into account…
-
2
votes2
answers3059
viewsTo group and remove lines with "null" values from this query in Mysql
CREATE TABLE tblCliente ( idCliente int(11), estado int(1) ); CREATE TABLE tblPergunta ( idPergunta int, idCategoria int, pergunta varchar(255), tipoResposta tinyint(1) ); CREATE TABLE…
-
2
votes2
answers5838
viewsCopy data from one column of a table to another of the same table
Hey, guys, I have a question. I need to copy the data from an integer column to another decimal column of the same table, that in Mysql. Is it possible to do ? there may be some inconsistencies in…
-
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
votes1
answer624
views -
2
votes4
answers32475
viewsQuery to catch word after given character
Good morning, I need a way to get all the rest of a string after a certain character, for example, I have the following database I always need to find what’s left of the string after the last "»"…
-
2
votes2
answers62
viewsDifficulty with creating SQL query
I am creating a view with the following query: select COD_PESSOA as ra, NOM_PESSOA as nome, COD_PESSOA_PAI as pai, COD_PESSOA_MAE as mae, from PESSOA This query returns a result like this: ra nome…
sqlasked 9 years ago Amanda Lima 3,428 -
2
votes4
answers311
viewsCreating Data Base through Stringbuilder
I am creating my database with the class sqliteOpenHelper, passing the creation of DB by String through the StringBuilder. The problem is, it’s just creating the first table, and then it doesn’t…
-
2
votes2
answers747
viewsHow to make database changes without having a clear primary key?
I need a method to change data in an SQL Server table. According to my client, all the table data can be changed. For having this possibility, I am without a fixed and unique reference frame for the…
-
2
votes0
answers110
viewsHow to build a structure from the same structure?
I have much search a way to mount a query in sql server but have not been very successful. First of all, I have a system that controls industrial patio in which there are organizational levels and I…
-
2
votes3
answers218
viewsPossibility to create 200 columns in a database
I am planning a software, which is a test of 200 questions where each question can only have 3 choices and select only one of them, and each question belongs to a class type ( for example question 5…
-
2
votes0
answers96
viewsWildfly in production does not recover properties and SQL script values
I am using a development environment and another production environment, in the development environment using the concept of i18n (Internationalization) is recovered correctly for example the value…
-
2
votes3
answers3504
viewsHow to remove the last character from a field in Firebird SQL
I have a field in a table that should only contain 4 characters, I realized that the same is with 5 characters and the last is the number zero. Example: Código Errado: 45380 Código Correto = 4538…
-
2
votes2
answers6895
viewsHow to define "charset" of a table in SQL Server?
In Mysql to define the charset of a table we can use so: Mysql: create table user_details (...) default character set = utf8; How can I do the same in SQL Server?…
-
2
votes1
answer50
viewsError retrieving SQL data
I have this code: SELECT Colaborador.IdColaborador, Colaborador.Numero, Colaborador.Nome, Colaborador.[Centro de Custo], Colaborador.Usuario, Colaborador.Responsavel, Colaborador_1.Nome FROM…
-
2
votes2
answers81
viewsHow to delete the first line of a megaheavy SQL file?
I have a "mega heavy" SQL file that doesn’t open in the sublime, nor in the notepad nor in gedit. I just need to delete the first line Use nome_database; to be able to import via the mysql Workbench…
-
2
votes1
answer160
viewsINNER JOIN with Where
I have the following tables : permissions_users id_user id_permissao permissions - id - permission I have a session variable where I have the id of user , I need to do a table search for id and…
-
2
votes1
answer36
views"order by clauses" can create conflicts between themselves?
It is possible that if we have several clauses in the order by, these conflict with each other? For example: select candidato.nome from candidato, perfil_oferta, prova_de_afericao where candidato.bi…