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
votes1
answer88
views -
0
votes1
answer177
viewsVB.NET - Public Shared Function
I have a function in a VB.NET system that I use to execute queries in BD. The function is Public Shared type for simplicity. And there is doubt whether competing accesses to the function could…
-
0
votes0
answers71
viewsRun SQL command on a virtual machine
I have a form, which has the login and password fields. I want to do an update sql command on a virtual machine to which of course, whoever runs the program will not have privileges to execute…
-
0
votes2
answers519
viewsSelect only the first record of a column
select below returns something of the type 005-A Produto A 21/AGOSTO 005-A Produto A 20/AGOSTO 005-A Produto A 21/MAIO 005-B Produto B 21/AGOSTO and I would like a registration per product equal to…
-
0
votes1
answer335
viewsList by Mysql and Java foreign key
I’m trying to select the dvds that the partner registered but I’m not getting, I wonder if someone can help me, the result of my code returns like this Result: 1 - null - null - null - null - null -…
-
0
votes2
answers1948
viewsSQL - set null values to 0
I have a table pivot that returns some null values in SUM(1). I wish they were zero instead of zero, but I’m not getting it. Pivot table original SELECT Description AS Categoria, [ACS], [URO] FROM (…
-
0
votes1
answer713
viewsMysql - Derivative Value Triggers
I looked it up and couldn’t find it anywhere. I am starting in Database studies and need the following help: A table Gang has the following structure: Id_class(auto incrementable)…
-
0
votes1
answer50
viewsProblem with Like for Criteria
Good morning. I have a table in the following format: I need to select to return the sum of infrastructure values grouped by year. I created this query in SQL: select YEAR(dataCompraInfra),…
-
0
votes1
answer55
viewsConnection between 3 tables to rescue information, sql
I have 3 tables with this structure I tried but could only enter two tables, but I would need it to be in the 3 to "save/clean" code. it is necessary to enter the table helpcenter_topics catch a few…
-
0
votes1
answer86
viewsError copying data from one table to another
Good afternoon Guys, I’m making an application that makes a Dvs loan request, I managed to make the application to enter the reservation, now I need to make the dvd owner confirm the rental and copy…
-
0
votes1
answer1561
viewsSelect except values (SQL / Oracle)
I need to improve this select that already exists here to perform a query where the ICCID initiated by 8995 are not returned, but I do not have much knowledge of database. How can I change this…
-
0
votes0
answers119
viewsOptimize SQL Code
I wonder if the one way I can optimize this sql code (mysql) that I did, the search is too slow, taking too long to bring the selected fields, I’ve done some tests but it’s still the same. SELECT…
-
0
votes3
answers296
viewsJavascript and SQL - Fill out a boleto with data from a row after selecting it
On a website, I have the following function in Javascript to bring me in a table the result of a query SQL. function buscaBoletos(){ $.ajax({ async: false, cache: false, url:…
-
0
votes1
answer49
viewsI can’t give a Grant in a schema
I am working with an SQL Server 2012 database and I am trying to assign a Grant to a schema with the following command: GRANT INSERT ON SCHEMA :: trunk TO trunk And I’m having the following mistake:…
-
0
votes5
answers3030
viewsCodeigniter -> Message: Trying to get Property of non-object
I’m trying to fix this bug: Severity: Notice Message: Trying to get Property of non-object Filename: contracts/view.php Line Number: 37 CODE: contratos_model.php public function getById($id){…
-
0
votes1
answer236
viewsFreight Table - District Listing
I have a table called bairro: I have a table called tabelafrete: I have the following SQL public function getBairroList() { $sql = "SELECT * FROM bairro as b Left join tabelafrete as t on b.idBairro…
-
0
votes1
answer479
viewsPredict next Bank ID
Good staff I’m wanting to better organize the images of the posts but for that I need to know what will be the next ID so I check the image first before entering the rest of the data. if…
-
0
votes2
answers230
viewsSearch with date range
In Mysql I have a table that has two DATE fields: data_inicial and data_final. In the System I have a Field (Textfield) where I type a date. This date does not need to be precise, but corresponds to…
-
0
votes1
answer99
viewsAssociate values of a dropdown with a specific column in the BD for query
I have a filter on my site that is in the image below: The real goal of the same is to "search" travel destinations (Ex:. Paris, Barcelona, Bahia etc...) and present on the screen the same. I have…
-
0
votes2
answers1544
viewsExport SQL Server 2014 Database
I need to export the SQL Server database to send to a friend. However I am not getting, I wonder if I copy these files and send to it, if it will work in his SQL Server (I do not know what version…
-
0
votes1
answer41
viewsList calls with or without idFunctioned
Sirs. I have the following function. $sql = " SELECT c.*, cli.*, cli.razaosocial as nomeCliente, c.idCliente as idClienteChamada FROM chamada as c, cliente as cli WHERE c.idChamada = '".$id."' AND…
-
0
votes1
answer126
viewsSort by position of edited record (sql server)
When I enter a new record, I make an ordination where I sort by the last entered record. SELECT TOP(50) * FROM TB_CLIENTE_FORNECEDOR where status <> 'S' order by IDCLIENTEFORNECEDOR desc If I…
-
0
votes1
answer171
viewsWhat’s the best way to do these triggers?
I wonder if there is a better way to write these Rigger. thank you --gatilho para gravar os dados do usuário CREATE TRIGGER TGR_TB_USUARIO_INSERT ON TB_USUARIO FOR INSERT AS BEGIN DECLARE @IDUSUARIO…
-
0
votes2
answers50
viewsJoin does not return the expected
I have the following scheme: tblpessoa with fields: idPessoa, name. tblcity com os campos: idCidade, codCidade, nome, idPessoa(fk da tabela tblpessoa), codigoRegiaoCidade(fk da tabela…
-
0
votes2
answers384
viewsHow to mount a select that brings information of which column is PK, which is not, and which is FK
I need a TSQL bring me some table information data as which column is IS_NULLABLE, COLUMN_NAME, and so on, but I came across a problem, I can’t bring a column in a CASE WHEN which says that such…
-
0
votes1
answer146
viewsQuestions for Swift app development
I’m working with an iOS app and I’m using Swift. My client who owns a restaurant would like to use an administrative panel to add new dishes to the app. I wonder if there’s a panel on the net that…
-
0
votes2
answers153
viewsIs it possible to use between to filter searches with a Character field?
For example, if I am going to do a database search of a table with the price of the products, I use in my condition Where: preco_product between 10 and 550 but and for me to do the same type of…
-
0
votes1
answer65
viewsConflicts in MS-Access
I have a table in an access database with the following fields: DATA | SALA | AULA1 | AULA2 | AULA3 | AULA4 | DOCENTE | TURNO ----------------------------------------------------------------------…
-
0
votes1
answer27536
viewsHow to include or remove enter, line break, new line from a string - Postgresql
How to remove or include "line break", "enter", "new line" from a string result in postgres. The result is: comentário Texto do comentário Mais texto And I want to: comentário Texto do comentário -…
-
0
votes3
answers2086
viewsReturn an sql command in a Function
I wonder if it is possible to return an sql command in a Function to run as a subselect. For example: Select *, produtos = (nome_da_function()) from Usuario Because the way I did I could only return…
-
0
votes2
answers227
viewsSQL Query, Join 4 tables, 2 group_concats + conditional, Help
Hello, I created an sql query to return all the client data in a single query, this query works partially if all conditions are satisfied, but this system uses soft delete, where all records cannot…
-
0
votes1
answer438
viewsHow do I handle data from a Date search in the Where clause in Postgres?
I have a screen where I have a list of a company’s payment titles, and I need to do a dynamic search from the issue date of the title. The idea is that when the user enters the date in a search…
-
0
votes1
answer45
viewsMs access 2 querys for the same comboboxes
Good to all I am programming a database and I would like to have a kind of 3 querys. I’ll try to be as precise as I can. I have 2 combination boxes that are interconnected, in this specific case…
-
0
votes1
answer48
viewsFunction upload multi attchements
I’m trying to create a function to upload multiple files at the same time but even with one get an error. What I might be programming wrong? 'FILE DIALOG OPENS UPLOAD PANEL Private Sub…
-
0
votes0
answers178
viewsLoad multi-attachements in various attachments in form
I am trying to create a function to upload multiple files at the same time but I think because I am choosing the next function does not actually attach the file but creates a preview. In my optics I…
-
0
votes1
answer238
viewsError inserting JDBC data
I’m having the following problem, I want to enter the data from my expense table but some error happens with my Foreign key, which may be ? background: Cannot add or update a Child Row: a Foreign…
-
0
votes1
answer653
viewsadd a foreing key to an existing table
I have to create a column in an existing table and at the same time create a foreing key with another table using this column that was created, and this foreing key by default has to be null. The…
-
0
votes1
answer94
viewsMy application does not change database data
I’m developing a software for a video rental company with MVC. There are two problems: not changing people’s attributes and displaying the following error: java.sql.Sqlexception: Column 'code' not…
-
0
votes1
answer82
viewsLike does not return data
I have a function in mysql that returns a decimal value. In this function it has a like. When I test sql in mysql the value is returned if I enter a letter or more than one. Ex: LIKE 'Home%'. As for…
-
0
votes1
answer155
views -
0
votes2
answers449
viewsHow to expedite VB.net database searches / Access97
Use a query searching in 3 different tables, returning this query attribute in a Datatable that will fill a Datagridview. The problem is that the search itself, this a little time, I used the TOP as…
-
0
votes1
answer408
viewsASP with SQL bringing different result of the query
Good afternoon! We are finishing a panel that will bring the results of an SQL in an ASP page. We already have two finished panels that are pulling the results perfectly. Only one of the panels does…
-
0
votes0
answers107
viewsSelect Advanced separated by hour
I rode a SELECT to return some information from my table separated by time and date. Until this part is all working correctly. Now I need him to select the same data only from another date, being…
-
0
votes1
answer137
viewsVertex closer to another - Postgis
Is it possible to return the nearest vertex to another? One of the observed geometries is a linestring. As in the figure below: I want to return the single vertex of the linestring (which is…
-
0
votes0
answers50
viewsReference a group of ID’s resulting from group_concat
I have a select that returns me the equally repeated lines, along with the total. I need to reference this ID group to pass as argument. The result of my query is the array below. Basically it…
-
0
votes2
answers49
viewsComparing variables in a query
Good need to create an if to check whether the field coming from the POST is empty or not, if it is should set null, if not I Seto the value that came in the variable. $query2 = "INSERT INTO…
-
0
votes1
answer112
viewsquery optimization that adds values according to a clause
Hi. I have a query that I must bring two columns, and one of the columns will return the value of a column, plus the sum of another column respecting the Where clause to add the values. I came to…
-
0
votes2
answers47
viewshow to limit sql column information
good evening, in a script I use added this string to get some information, <div class="col"><b><?= $this->lang->line('imei');?>:</b>…
-
0
votes1
answer59
viewsSQL JOIN - Build according to base
I would like to elaborate an SQL using LEFT JOIN. I wrote this SQL, but it didn’t work: SELECT *, p.parametro AS cidade, cpr.codTipo AS tipoAcompanhante FROM cadastroperfil AS cp,…
sqlasked 9 years, 3 months ago Sr. André Baill 6,946 -
0
votes1
answer118
viewsQuery with two summations for the same column
It is possible to make a query in which in the same query two sums are executed on the same column? Here’s what I got: Total sum of sales select month(emitido_date) as mes, ifnull(sum((det.preco *…