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
votes2
answers96
viewsCorrect code to select and compare
I want to select * from table A that are different from table B and have used the following code: select * from Tabela A inner join Tabela B on A1 != B1 and A2 != B2 and A3 != B3 but the computer…
-
0
votes1
answer593
viewsField as parameter in Generic Update - ORACLE
Currently I have a precedent that reads an XML, and updates the table fields personal based on the values sent by XML, such as CPF, RG, Name, etc. Today I read the XML values and insert in the table…
-
0
votes1
answer160
viewsProblem with full Outer Join filtering with Where
Friends, I have a database with the following tables: guys id | nome 1 | Duplo 2 | Triplo availability data | tipo | ocupado | manutencao | referencia 01/03/2018 | 1 | 1 | 0 | 54684 01/03/2018 | 1 |…
-
0
votes2
answers231
viewsHow to make a SELECT keeping the first column until the records are finished
I would like to do a SELECT that repeats the first column, but when all the records are finished, change the data in the first column and repeat all the records again. Let me give you an example to…
-
0
votes1
answer243
viewsHow to separate emails by semicolon in SQL Server?
I have a column that has several emails separated by semicolons, I would like to know how to separate these emails and insert separately in another table. In the image below is more detailed.…
sqlasked 5 years, 8 months ago Diego Luques 19 -
0
votes2
answers206
viewsMysql - auto increment shared between tables
It is possible to share the auto increment value of two tables? Example: Tabela 1 +----+-------+-----------+ | id | campo | criado_em | | 1 | a | 00:00 | | 2 | b | 01:00 | | 5 | c | 04:00 |…
-
0
votes1
answer3898
viewsHow to generate a counter within a select (SQL server)
I need to make a select with a case, if the condition is true use a counter that will be a new column, otherwise the counter will be displayed without any change, but I’m not succeeding, I tried…
-
0
votes0
answers447
viewsSQLSTATE[HY000] General SQL Server error: Check messages from the SQL Server (Severity 14) (SQL: select * from [product])
I have an application in Laravel connecting in the database in an SQL Server when I will make a query of all products I am getting the error SQLSTATE[HY000] General SQL Server error: Check messages…
-
0
votes2
answers80
viewsI can’t see the error (PHP and HTML)
I wanted to show the names of the employees and the teams that they are part of so that if the user enters a name, it will filter all the teams that that person is part of. It’s coming in white.…
-
0
votes0
answers586
viewsRemove SQL Server special characters
how do I remove special characters from a string in a query in SQL Server with tags in html, xml and others? Current result: <!--[if !mso]><styl>v\:* {behavior:url(#default#VML);}o\:*…
-
0
votes1
answer640
viewsHow to Count With Subquery
I need to count table fields, however, these fields have different types of filters within Where. I need to be shown the consolidated information, I tried to do openquery but returns error. select…
-
0
votes1
answer209
viewsCannot find Symbol - NETBEANS
I was programming, so far so good, but when 'getar' +txt_endereco.gettext()+ gives cannot find Symbol, when I go 'setar' the same thing 'txt_endereco.setText(model.getValueAt(indexrow, 4).…
-
0
votes1
answer844
viewsCreate HTML list with SQL query return
I need to return the query SQL on a list HTML. In the precise case of line with "affiliate" and "name", the query below, returned correctly the requested data, but now I need to put this data one…
-
0
votes0
answers74
viewsSql does not recognize the pelica
I have a problem where sql does not recognize the pelica <div class="col-md-6 form-left"> <select name="utilizadores" > <option value="0">Utilziadores ativados</option>…
-
0
votes2
answers44
viewsChanging positions of an integer
Citation I am building an sql where I have the following information yyyymmdd 20190327 is in the database as integer, I need to convert into ddmmyyyy 27032019 continuing to be an integer in select.…
-
0
votes1
answer474
viewsHow to enable mysql Workbench connection manually
I would like to know how to manually activate the connection in Mysql Workbench, without the aid of a command IDE like xampp. As I remember if I was making this connection via computer management,…
-
0
votes1
answer62
viewsOnly get the lang of the clicked class
I need to take only the lang value of the clicked item, but only takes the first value. I don’t know how to solve php: $i = 0; while($rowFoto = mysqli_fetch_array($matrizFoto)) { echo "<div…
-
0
votes1
answer265
viewsHow to get id of a CRUD element [Codeigniter]
My question is this: I have a CRUD done in CodeIgniter, but the table rows are not in format localhost/crud/produtos/[:num]. In the last column of the table there are action buttons to edit and…
-
0
votes1
answer23
viewsReturn message using declare?
I need to check a variable on MySQL similar to that of the SQLSERVER. where i check return on a variable in the bank’s own message example in SQLSERVER I do so: DECLARE @nome VARCHAR(20) = 'NOME'…
-
0
votes2
answers42
viewsSQL formatting field
I have the following structure: |VALOR| | 1 | | 23 | | 5 | | 41 | I have a need to transform: | VALOR | | 0001 | | 0023 | | 0005 | | 0041 | Is there any function I can do that?…
-
0
votes1
answer39
viewsAsp net mvc project integration with sql server
How can I connect visual studio with sql server galera? I made a registration screen, but I have no idea how to make my site send this data to sql server?
-
0
votes1
answer2984
viewsOracle sql - Expression not found
What I’m trying to do is this: List the names of the Cds that have a sales price greater than 10.00 reais or the label is code 3, ordered alphabetically by decreasing the names of the Cds. Show CD…
-
0
votes1
answer132
viewsSELECT with LEFT JOIN successfully but some wrong results
I need to make one SELECT using 2 tables with LEFT JOIN, I successfully get the query, but it brings me some columns with wrong results. The results of the First table are: tbEntregas…
sqlasked 6 years, 8 months ago Maurício Sanches 487 -
0
votes0
answers135
viewsKnapsack Problem (Backpack Problem) SQL SERVER CTE RECURSIVE
Good afternoon. I am trying to develop a solution within the ERP of the company in which I work, with the objective of identifying the possibilities of INVOICES summed whose TOTAL is equal or…
-
0
votes2
answers70
viewsDoubt in an SQL DISTINCT
I have the following select: SELECT DISTINCT CD_CLIENTE, CD_CONTRATO, CD_AGRUPADOR FROM TBP_IMPORTAR_OS_RESIDUO WHERE CD_USUARIO = 0 But I wish when the field CD_AGRUPADOR were the same, bring only…
-
0
votes2
answers91
viewsHow to create a form where it stores the data in a table and at the end you can register the data in the table in the Database?
I am creating a form where you register by entering 5 data (5 fields), and then when pressing the "Add" button, this data would be added in a "table" below where it shows your number, name and can…
-
0
votes2
answers509
viewsHow to map multivariate attributes?
I am trying to map this conceptual model to the logical, but I have doubts about how to map the multivariate attribute "palavra_chave" that will allow the registration of as many keywords as the…
-
0
votes1
answer203
viewsFind shift based on a given date time in ORACLE/sql
In a table X I have a date column that also returns the time, I wonder if, based on this time, I have how to create a column with the name of the turn. ex( if you have a die 20-02-2002 06:00:00 I…
-
0
votes1
answer66
viewsHow to process in Mysql with select
I would like to know how to create a project that select in several fields of a table. Would be a select list, I tried to do but I have no idea where to start. DELIMITER // CREATE PROCEDURE…
-
0
votes1
answer31
viewsHow to ban a DDL action on oracle
I want to do a Rigger that prohibits any DML operation on a given table. In case these are the parameters: between 20:00 to 06:00, and Sunday all day. CREATE OR REPLACE TRIGGER TG_HORARIO BEFORE…
-
0
votes2
answers264
viewsRemove First Name and Last Name from Full Name
I am using the SUBSTRING_INDEX command to get the first name and last name of a table field "Names". SELECT SUBSTRING_INDEX(nome_completo, ' ', 1) AS primeiro_nome, SUBSTRING_INDEX(nome_completo, '…
-
0
votes1
answer1443
viewsIntegration of SQL Server with Android
I’m having trouble connecting to Sql Server and Android. When I try to communicate, the message appears: "No address Associated with hostname." I’ve done everything I needed, already downloaded the…
-
0
votes0
answers52
viewsOR logic operator in sparql
I’m trying to build a sparql query using Or, like: SELECT ?a ?b ?c WHERE (?a :property ?b **OR** ?b :property ?c **OR** ?a :property ?x OR .....) ... ms I cannot use, because it throws the following…
-
0
votes1
answer33
viewsStructuring a database
Good Morning. I am structuring a database for a project and would like to know if it is possible to have a database(or table) with only foreign keys to connect to all other tables, or is it…
sqlasked 5 years, 7 months ago Filipe Fernandes 3 -
0
votes1
answer63
viewsSQL "Where" problem
I am doing a query in SQL and as a constraint I want the query to return the data from the first day of the previous month until today. For example: If I run today (10/04/2019) the query, will…
-
0
votes1
answer303
viewsAverage and filter by values above this mean
I would like to average the amounts spent by all customers. Then list the names of customers who spent above average (can be using inner join, but with sub-consultation): SELECT a.primeiro_nome,…
-
0
votes0
answers380
viewsSQL query with start date and end date
Guys, I need to consult some values in a table, I have to bring the values of the day 23/02/2016 until the day 23/02/2018, I tried to do in SQL but it did not work so right, code below: SELECT…
sqlasked 6 years, 8 months ago Lucas Lemos 1 -
0
votes0
answers45
viewsSelect location from status
I have the following structure (fictitious) Status table: id | name | status Table location: id | title | estado_id In my front-end I have a navbar which will list the states and in each state the…
-
0
votes1
answer99
viewsProblems with executescalar (System.Data.Sqlclient.Sqlexception)
I have the following block of code: sqlConn.Open(); SqlCommand inserirAluno = new SqlCommand("INSERT INTO ALUNOS (Nome, DataNascimento, CPF, Endereco, Bairro, " + "CEP, Cidade, IdEstado, Sexo)…
-
0
votes0
answers26
viewsDisplaying forms through Select with Jquery
I have a select field for the user to choose which form to register the data! ( 2 forms to be displayed). When selecting the first option in select, I am using Jquery Hide() and show() to display…
-
0
votes2
answers39
viewsComplete number of query records
Hello! I have a table in BD that can contain from 0 there are 12 records. (as a monthly income chart during the year. totaling 12 records) I want to make a query in this table and I want it to…
-
0
votes1
answer148
viewsWhat is the Difference between Select and Run in a Procedure?
There is some difference between making a Select to call the Procedure and giving a Execute in the Procedure, for example, in select a Procedure is in Read-Only mode and in execute no?
-
0
votes1
answer156
viewsINTO OUTFILE command saves file without header, how to set header?
Good afternoon, everyone, I am running the following command to save files coming from MYSQL. Works however I cannot save the file with header, the data comes without header. SELECT * INTO OUTFILE…
-
0
votes1
answer1101
viewsSQL SERVER - return different columns from an Inner Join on the same row
I have the following scenario: Table users Table users On the table usuariosacessos, each line has the id user, the name of the functionality, and a field stating whether or not it has access. In my…
-
0
votes0
answers270
viewsCategories and subcategories in a single SELECT
I have the following table structure: CATEGORIAS id titulo SUBCATEGORIAS id id_categoria titulo I was wondering if there is a way to bring all categories and subcategories at once into a single…
-
0
votes3
answers931
viewsSql Help that queries 2 fields from the same table
I have the following problem to solve: I need to make an Sql that refers to an X table "Tabela X": id coluna1 coluna2 "Tabela 2": id coluna1 coluna2 coluna3. In "Table X" column 1 and column 2 are…
-
0
votes1
answer77
viewsHow to subselect/subquery using Criteria
Can someone help me find the problem of this consultation : CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Solicitacao> query = builder.createQuery(Solicitacao.class);…
-
0
votes1
answer36
viewswork with images in sql server + Asp net
Guys, in my project I need to work with uploading images through the site Asp.net and save them in sql server, and then I need to show them on a page as if it were products, with description and…
-
0
votes1
answer87
viewsHow to update to a column of another table automatically when doing an update using Trigger?
CREATE TABLE TB_Empregado( nome varchar(50), rg int primary key, cpf varchar (11), salario money ) --- CREATE TABLE TB_Dependente( rg_responsavel int constraint fk_TB_Dependente_Empregado references…
-
0
votes0
answers92
viewsHow to run the JOIN command in ORACLE?
Hello. I am having problems with my query at ORACLE, someone would tell me how to solve it ? SELECT C.NRO_CONTA, C.NOME, C.SALDO, SUM(RESULTADO.COTAS) FROM CONTA C JOIN FUNDOS_APLIC AS RESULTADO ON…