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
-
1
votes3
answers121
viewsSelect union rest between tables
I have two tables, customers and sales. I would like to know which customers have no sale, and store in the sales table the customer ID. I tried it but to no avail: SELECT * FROM cliente RIGHT JOIN…
-
1
votes1
answer47
viewsHow to operate with Union
Guys I’m trying to do an operation with this two query but I don’t know how. select sum(total_atend) total_atend, sum(total_infect) total_infet From ( select count(atendime.tp_atendimento)…
-
1
votes1
answer136
viewsDisplaying null results for mysql related tables
I need to create a relational query that returns records containing data from both the PERMISSAO table and the USUARIOS table. ALL PERMISSIONS records must be displayed. When there are no USER…
-
1
votes2
answers239
viewsRetrieve database records by date field?
How do I recover users recorded in a database table by the dt_birth field through two values representing the minimum and maximum age of the users that will be returned, the minimum and maximum age…
-
1
votes1
answer110
viewsJava project with Oracle and Mysql at the same time?
In view of an Oracle BD and a Mysql BD, and the impossibility of integration of both bases: It would be possible, for example, a class of my application to 'look' at the mysql table and update an…
-
1
votes4
answers2129
viewsSQL query with ID from a combobox - C#
I’m putting together a little system where I created a Formulario where there is a Combobox listing the names of the employees stored at the bank and a DataGrid that shows the services done by them…
-
1
votes1
answer177
viewsSQL: Can I have clauses in Groupby that don’t appear in Select?
I know I can’t have clauses in select that don’t appear in Group By. But is it possible otherwise? For example: Select B From Table Group By A,B
-
1
votes1
answer84
viewsSQL how to make me return the number of negative intervals (INTERVAL of date)
dif_active date_fimdegus is a range of the difference between 2 date fields, which return me, for example, -1 day. I wonder how I can make a Count of all records that are negative in this column.…
sqlasked 9 years, 6 months ago Lucas Emanoel 31 -
1
votes1
answer66
viewsError in Namedquery
Good evening guys, I’m looking to create a namedquery with a bank appointment. Follows: @NamedQuery(name="ListagemProdutosMesa",query="select Produto p FROM Produto p, Pedido pe, Conta c,…
-
1
votes1
answer630
viewsInner Join, multiple Inserts with multiple conditions
Well, the thing is, I don’t understand where I should start, if I should select customers first, anyway, I’m sure I’ll use inner join or some joiner because it uses other help tables. I wanted help…
-
1
votes1
answer1409
viewsSQL syntax error
I come again with a similar error in my SQL syntax. I have tried a few times and so far nothing. If you could give me a hand, I’d appreciate it. Just follow my code: $sql="INSERT INTO processos (…
-
1
votes1
answer4302
viewsFirebird - transaction monitoring
I updated my Firebird to the versão 2.5 and would like to view the transactions, I saw in several links that the command: SELECT * FROM mon$statements solves, but this command gives me a mistake:…
-
1
votes3
answers381
viewsUse query within the value of another query
It is possible - with some syntax adaptation - to fulfill the objective of the following query? insert into X (a, b) values(16, select c from Y where d = e)
sqlasked 9 years, 6 months ago Rafael Barbosa 2,855 -
1
votes1
answer230
viewsTransfer date value from Form1 to class c# windows form . net
I’m working with windows form . net c# but I don’t have much practice and would like a help... I have a calendar component in a Form1 and after running the application, a date is selected which is…
-
1
votes1
answer88
viewsIncremental key
Guys, I’m doing a web service with Java + Postgres. I set my table in Postgres as follows: CREATE TABLE usuario ( id serial NOT NULL, nome character varying(40), idade integer, CONSTRAINT…
-
1
votes0
answers111
viewsSql exercise
Good afternoon guys I’m doing the following exercise but I’m in doubt whether I did it right or not, could you take a look? Write the SQL queries according to the database schema present below. a.…
-
1
votes1
answer962
viewsQuery SQL returning duplicate records
I have two tables (adwords_performance and analytics_transaction) and I need to make a SELECT adding up the columns adwords_performance.clicks, adwords_performance.impressions and…
-
1
votes1
answer15538
viewsHow to run a trial in a select?
What I tried was the following, and my Procedure returns only a select: SELECT * FROM t_usuarios WHERE nome like '%jeniffer%' AND cd_usuario IN (exec usp_lista_emprestimo_em_atraso) ORDER BY nome…
-
1
votes3
answers74
viewsHow to select information from a table without duplicate values
Let’s say I have a table called ALUNOS, with 3 columns, ID, NAME, SOBRENOME And I want to take all SURNAMES, but in a way that does not duplicate if a student has the same surname as another…
sqlasked 9 years, 5 months ago Léo Soares Fontoura 65 -
1
votes1
answer108
viewsSQL database for multiple users
Well, I have a question. I am developing a web application that will suit more than one user, however each user has different data recorded in the database, and this volume will be great, since the…
-
1
votes1
answer142
viewsHow to use Scope_identify to return id . NET
I am developing an application and need that when sql does the Insert return the value of the id that was inserted, I am using the following command SqlCommand cmd = new SqlCommand("insert into…
-
1
votes3
answers403
viewsOnly first row of table being displayed!
I’m requesting the table data this way: $sql = "SELECT * FROM `login` order by `userid` DESC"; $limite = mysqli_query($db, $sql); while ($sql = mysqli_fetch_array($limite)) { $account_id =…
-
1
votes3
answers749
viewsHow to optimize the query in a remote bank using Clientdataset?
I’m using a Clientdataset for consultation in a remote database, the table has more than 100 thousand records and this getting very slow, the SQL I am using is: select (coalesce (cast(A.con_baixa as…
-
1
votes3
answers1239
viewsCode to display the login client data
Well my question is this, when logging in how I get session data? I think it’s a select, but when I do it I have to create a session? Because I want to search the data only of this client who logged…
-
1
votes1
answer1124
views -
1
votes2
answers79
viewsError in the procedure
I’m new to creating PROCEDURE. I am trying to create this PROCEDURE plus this tando error. DELIMITER // DROP PROCEDURE IF EXISTS `P_lgs`; CREATE PROCEDURE `P_lgs` ( idcod INT, dt VARCHAR(20), ip…
-
1
votes1
answer96
viewsSql query return the same name with different date
My table Acidente is more or less like this: Vitima - DataRegistro Pedro - 10/02/2015 Pedro - 20/03/2015 Maria - 01/05/2015 Maria - 01/05/2015 I need to make a query (Sql) that returns the records…
-
1
votes0
answers35
viewsUpload xlsx Spring MVC and compare data with SQL
I’m trying to upload an xlsx file and compare it to my database table, but I’m not getting it, as my file is too big I can’t read it with Apache POI and then compare it with the SQL table. Can you…
-
1
votes2
answers1421
viewsHow do I convert a SQL Server backup file into . BAK for . CSV?
The file was generated from SQL Server. I would like to convert it into a visual file, type . CSV, it is possible?
sqlasked 9 years, 4 months ago Flavio Neves 11 -
1
votes1
answer29
viewsSql last ids
How do I return the last 5 id with sql? NAME ID 1 John 2 William 3 Alberto 4 Alexander 5 Michael 6 Luke And you will return: 2 William 3 Alberto 4 Alexander 5 Michael 6 Luke
-
1
votes1
answer481
viewsQuery using Linq to sql in Asp.net MVC
I have a question about how to return the records according to the query. I don’t know what could be wrong, but the query is not returning according to what was past. I have my controller: public…
-
1
votes1
answer875
viewsHow to count the number of comma-separated items in Mysql?
I have a field in a table with data separated by comma: condicao_pagamento: 20,25,35,45,50. How do I count the number of comma-separated items using Mysql only?
-
1
votes1
answer246
viewsHow to select smallest record by field
How can I present the smallest factor by ID_ACORDO? SELECT LIGACOES.ID ,ACORDO.ID_ACORDO ,ACORDO.DATA as 'DATA_ACORDO' ,LIGACOES.time_of_contact AS 'DATA_LIGACAO'…
-
1
votes1
answer1315
viewsHow to run a script before a view on sql server?
I created a view and it looks for information from an X table. Only this table X, must be created in a select, before executing the view, for the data to be updated. It has to create something in…
-
1
votes1
answer719
viewsCreate a dictionary in Python by receiving values from the database
After accessing the database and have the desired query in case: ... c = conn.cursor() c.execute('SELECT `tb1`.`Nome`, `tb1`.`Apelido` FROM tb1') How to create a python dictionary for my command…
-
1
votes1
answer271
viewsRemove fixed-sized part of an xml
People, I have this piece of an XML and I need to remove the value (357122.40) that is between the tags < vMerc>xxxxxx< /vMerc>. Only this value has no fixed size.…
-
1
votes1
answer804
viewscheck the time periods available in the SQL table
I am developing a schedule for a software that manages schedules available for scheduling, it seems strange that I post this here more by incredible that it seems not found anything of the kind here…
-
1
votes1
answer4011
viewsUpdate sql with 2 conditions
I have a table with the column STATURE This column consists of 3 possible values: NEW, VISUALIZED, DISCARDED I have a function where I need to implement an SQL row that updates my table and changes…
-
1
votes0
answers34
viewsProblems with updating datagrid C#
I have a code that’s responsible for scrapping stocks of a particular product in a product chart... it cuts the stock down without a hitch.. but when I go to the Product Stocks Search Form the…
-
1
votes0
answers490
viewsExport Mysql users and permissions to another server
I am making another server with the same databases as the previous server (I already migrated the databases) and would like to migrate the users and permissions from this previous server to the new…
-
1
votes1
answer148
viewsCondition in Mysql for data query
Is there any way to make a condition to demonstrate data only if the status be as aprovado in the database? Mysql: Nome ProdValor Data Status Goku 250,00 15/04/2015 Aprovado Goku 250,00 15/04/2015…
-
1
votes1
answer282
viewsGet query result by converting Date Time field to local Time zone
I have a table in the sql server database that has the following Datahora field where I have data included in this following format: DataHora 2015-04-20 17:43:04.000 this time is not in the format…
-
1
votes2
answers100
viewsDynamic TSQL for multiple returns
I need to make multiple inserts that will depend on an existing result in a table like this: --CRIA TABELA #CONTATO CREATE TABLE #CONTATO( NOME VARCHAR(100) NULL, TELEFONE VARCHAR(50) NULL );…
-
1
votes2
answers1312
viewsUse SQL LIKE to find a number followed by space
I have a field that gathers values that are sequences of numbers separated by space and comma, such as: "1 , 2 , 3 , 23 , 41 , 54" I was using SQL inside PHP to find a number inside this field with…
-
1
votes1
answer45
viewsConcatenation of a Select field into the ADDTIME function
"SELECT at.codigoTurma, " "ADDTIME(t.horaInicioCurso, '00:01:00'), " "t.toleranciaCurso, " "t.horaFinalCurso " "FROM AlunosTurmas at " "INNER JOIN Turmas t " "ON t.codigoTurma = at.codigoTurma "…
-
1
votes1
answer53
viewsSelecting subcategory by category
Having the following tables in the category and subcategory bank: CREATE TABLE categories ( id INT AUTO_INCREMENT PRIMARY KEY, category_name VARCHAR(255) NOT NULL, created DATETIME, modified…
-
1
votes1
answer490
viewsError returning mysql database data
I made a normal form that returns the data in HTML. So I decided to insert images in the database and then gave a warning: "Notice: Array to string Conversion in E: sites htdocs progdesenv2 admin…
-
1
votes1
answer1310
viewsJPA - Two Onetoone and Onetomany relationships between the same class
I own a student class and she has two relationships with Pessoa one OneToOne and OneToMany and person in turn a relationship with Endereco, as shown below: Classe Estudante @Entity @Table(name =…
-
1
votes1
answer640
viewsSave input field to database
How to store the last 100 searches made to a website (PHP/MYSQL) divided by countries (e.g., store the last 100 searches for books in Macedonia). Search is a simple field: <input type="text"…
-
1
votes1
answer359
viewsRelating various data from one table to another with SQL
I needed to list, with SQL, a person’s father, mother and spouse along with their general data (e.g.: name, address, telephone, email, father, mother, spouse, status). This data is in another…