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
votes1
answer1163
viewsProblem with (Sql Server) insufficient system memory in Resource pool
I have a problem in some queries performed by the system, I analyzed the code and there is no error, more the bank is returning me to the message "There is insufficient system memory in Resource…
-
1
votes1
answer222
viewsMerge JSON Postgresql column data when performing UPDATE
The scenario is as follows, I have a JSONB type column in my database where a JSON structure is saved. What I need is that when this structure is updated, it will update only the keys that have been…
-
1
votes1
answer235
viewsI’m having an error in stored Procedure , probably within IF
To procedure must insert a client with at least 10 characters in name, Uf(Federative unit) with 2 characters and monthly reindeer with more than 500.00. Follow the query: DELIMITER $$ CREATE…
-
1
votes1
answer1116
viewsMake a "distinct" in a query with many fields in select
In this query, can I do a sort of distinct? A Group By is very slow and there are many fields. Pure distinct does not solve, as there are several fields. How would that be? DECLARE @CodTerceiro int…
-
1
votes1
answer301
viewsCreating a String in Postgresql
So, I have this sequence in a column of a table where every time I do an insertion its value is defined by nextval ('ptable_pr_codigo_seq' :: regclass) CREATE SEQUENCE public.ptable_pr_codigo_seq…
-
1
votes1
answer43
viewsProcedure SQL Serve c/ ASP
good afternoon! I have this basic process in SQL Server, which brings me the spending percentage: DECLARE @totalDespesas FLOAT ,@totalDespesasAcomp FLOAT ,@resultado FLOAT SET @totalDespesas =…
-
1
votes0
answers61
viewsQuery SQL in my Controller does not run on Server Error 1142
I created a website with Laravel 5.7, and uploaded to the server with the databases, all ok. All functions of my controller perform perfectly, except the Function down below: public function…
-
1
votes0
answers115
viewsHow to upload images with different id
I want to know how I can upload images with different id or I have a functional upload system only this system is an id only, I want to know how to do for each image sent the id change or I have an…
-
1
votes2
answers2244
viewsHow to calculate the cumulative sum in Oracle
Hello, I have a table with a lot of data, and I would like to count the amount of records in each date of this month. So far OK, a COUNT(*) and a GROUP BY already resolves. SELECT…
-
1
votes0
answers48
viewsHow to handle the return of a query in the PHP database
I’m having a hard time creating the logic for handling/processing the data I receive from an SQL query in the database. My query is returning an array in the following format: My array: array = {0:…
-
1
votes1
answer65
viewsHow to unite results of queries without mixing them?
How can I join 2 query results without mixing them? For example: The first query results in names starting with Victor, the second results in names containing Victor. Result of first consultation:…
-
1
votes0
answers34
viewsurl giving 404 error when adding page
good afternoon guys, I have a huge "headache" here on the trampo, I’m trying to add page on a site here, but it’s not working: I have to add a url like this: /novapagina sem extensão, but in htacces…
-
1
votes1
answer39
viewsSimultaneous database login - efficiency
Hello! To prohibit simultaneous login of the same user in a local PHP system, where it will have a maximum of 50 long-term users (initially between 15 and 20), I created a table in the database,…
-
1
votes2
answers90
viewsHow can I Create a column in SQL SERVER where, depending on the value, debt or credit appears?
Good friends, I made a program where I import data from an excel file in the sql database, this database is about values, and etc... And wanted to know if you have how to create a column where after…
-
1
votes1
answer43
viewsHandling of empty fields
In this query, I have some stores that have not identified sale. Bringing the result as null. This impacts on the field of percentage and total. How could I make null fields to be interpreted as 0…
-
1
votes1
answer89
viewsTake data from a table through an N:N relation
I have a system made in PHP and Mysql where I have two types of registration, teacher and student. On this platform, the teacher can add a student as "friend" and the student can also add a teacher…
-
1
votes1
answer118
viewsDoubt with the Function window in Postgresql
I have a job for college and I have a question in an exercise that I have to use the window functions to make the correct query. This is my query: SELECT pais, modelo, fabricante.nome, (venda.valor…
-
1
votes2
answers500
viewsSelecting data and organizing by 15min Sql interval
Good afternoon, I have the following query that returns the amount of vehicles on the track between a certain time. But I want to take this interval between times and set intervals between 15min.…
-
1
votes0
answers244
viewsCreating random password in Mysql database
Good morning, I’m trying to create a Rigger that generates a random password with uppercase letters and 0-9 numbers in a database password field, as it is possible to do this Rigger ? [FUNCTION]…
sqlasked 5 years, 6 months ago Jackson Felipe Magnabosco 140 -
1
votes1
answer669
viewsSet variable with SELECT and WITH in SQL Server
I am trying to set the variable with a query, select only works this way using WITH, but it is giving error when I will assign the value in the variable. The code I’m trying to: DECLARE @contador…
-
1
votes1
answer68
viewsPass SQL values to another Ionic 3 page
I have an input on a page that is stored in the database and would like to show what was stored on a new page. </div> <ion-list> <ion-item> <ion-input type="text"…
-
1
votes2
answers939
viewsHow to compare Select
I have a query in Oracle a select with some sub selects, I have to consult several tables and bring all the data in the main select a single Row, I have two sub selects of the same table and I can…
-
1
votes1
answer172
viewsSummarize fields with direct calculations in sql query
I don’t know how to do it I’ve tried almost all day and I can’t if any can help... The problem is I have to add a field that is sine calculated in the direct sql query. Sql: SELECT…
-
1
votes1
answer40
viewsDoubt - SQL Server - Using Union
Guys, I got the following Union: select cgc, item, matricula, cota, dataInicio, dataFim from [dbo].[cotas] as t1 where dataFim is null union select cgc, item, matricula, cota, dataInicio, dataFim…
-
1
votes0
answers92
viewsTrigger to ban scale insertion that is already working on that SQL Server date
Thank you for your time! 1° I’ll put the data and then I’ll point out my doubt, I’ve tried a thousand times and I can’t get the logic that works. I have the following table Scale Table CREATE TABLE…
-
1
votes1
answer47
viewsSQL query does not return expected items
I have two tables called Protocol and Analyze with a 1:n relationship, a Protocol may have several Analysis, Protocol has a composite primary key. I need to write an SQL that returns the Protocols…
-
1
votes1
answer114
viewsI have a Java class where one of the attributes is an Arraylist of another object. How to bring this from the database?
I have a java object that looks like this: public class Objeto1 { private int id; private int nome; private ArrayList<Objeto2> lista; //construtor e Getters e Setters } How do I get this list…
-
1
votes1
answer32
views -
1
votes1
answer29
viewsHow to store records in tables when they have Foreign Keys?
My database has 6 tables: --Movies table MovieID int PK, MovieName varchar(50) MovieDescription text, MovieCategory varchar(50), MovieYear varchar(4), ParticipationID) --Series table SeriesData (…
-
1
votes2
answers69
viewsQuery with more than one view field
I have doubts about how to perform the query displaying two fields, with only one. I have the Clients Table (id, name, date of birth) and the Transactions table (id_trans, id_clien, valor_trans). I…
-
1
votes1
answer721
viewsHow to create a @Onetomany relationship in JPA, in 3 tables that already exist in the database?
I want to create a relationship @OneToMany in JPA using 3 tables I have already created in my database (I don’t want it to create the tables for me), the tables are Usuario, Perfil and…
-
1
votes3
answers216
viewsHow to take the value of a Database table field and use it in a PHP variable?
I have the following question: I have a condition if else in php the problem is that I need a value inserted into a field in the database table for the script fulfil the condition of if or of else.…
-
1
votes1
answer69
viewsIs it possible to optimize my code for a single query?
I have the following problem: I’m assembling a Highcharts chart with queries php and I end up having a while inside another because the result of the date I put in the next query, has to return in a…
-
1
votes2
answers905
viewsProblem creating a Foreign key
I created a table tbl_cond with a PRIMARY KEY calling for ID_cond When creating a second table with a FOREIGN KEY, being her ID_cond of tbl_cond, put the following code. use db_clientes create table…
-
1
votes1
answer956
viewsAdd a 'Virtual' column to a SELECT in Oracle
I would like to place a temporary column that was generated only in the query that will be linked to CD_NIVEL say, "If CD_NIVEL = 5 creates a column 'Exclui' as if it were a description of what the…
-
1
votes1
answer46
viewsQuery to remove duplicates entering apparent infinite loop
I have several fields in my table but I have 4 that are being repeated and I cannot allow registration with these equal fields: COD, TIPO_ATIVIDADE, DT_VENCIMENTO, `EXTRA_URGENTE_COMUM. I have tried…
-
1
votes1
answer54
viewsHow to use Join or Aggregate in SQL query
When performing the query in a given table, numOrc is a list that may contain one or more values. So I needed to concatenate these values into one string, using ; as a limiter. So I tried: var model…
-
1
votes1
answer100
viewsError in GROUP_CONCAT Access function
I am performing the following SQL: SELECT e.titulo, e.descricao, e.obs, e.cupom, e.inicio, e.fim, GROUP_CONCAT(p.nome) AS teste FROM ((eventos e INNER JOIN produtoseventos pe ON e.idevento =…
-
1
votes1
answer66
viewsWith mounting a query dynamically depending on a typed string
I’m mounting a search in the database where the user informs an example text: "how to configure windows". Currently I have a select which works as follows: $query = "SELECT resposta FROM suporte…
-
1
votes2
answers101
viewsHow to use more than one LIKE in PDO bindValue
I’m having a hard time making an appointment SQL with the bindValue from PDO. I need to pass more than one value in the clause query like :cc plus the value returned is 0. If I use only one value…
-
1
votes1
answer110
viewsQuery with 3 conditions AND does not work the last condition
I would like to make a query in two tables that takes into account 3 criteria, but is not presenting the expected result. Select viaturas.vtr_numero From viaturas, despacho_ocorrencias Where…
-
1
votes1
answer450
viewsSave Captured Data and Executed Commands with Python
I need to use Python to make several commands on a system, and at the same time go saving in a dataframe everything that is being done. There will be hundreds of commands per minute, for several…
-
1
votes1
answer74
viewsQuery to not repeat an already registered value
I have the following situation: I need to make an SQL query in a field to return only the vehicles that are registered in a form (table vehicles) and that the form despachos_ocorrencias the vehicles…
-
1
votes1
answer88
viewsOracle SQL Function
How do I perform the function that returns the number of credits for a given course by blocking the code? As the example at the end. TB_DISCIPLINA COD_DISCI DESCRICAO CREDITOS TB_CURSO_COD_CURSO…
-
1
votes1
answer85
viewsWhy do space aliases only work with backticks?
I have a view where all its columns have been dubbed to make it more readable: +----------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra |…
-
1
votes1
answer59
viewsUpdate field value in Mysql using PHP if condition
I have a table in Mysql named "Register" where it has the following fields: id - Type: Auto Increment - Primary Key dataCadastro - Type: Date statusFK - Values 1 (On) and 2 (Off) ---> In the case…
-
1
votes1
answer44
viewsC# Conversion Error when trying to save to SQL Server database
I’m new to C# and I’m taking a beating to record texbox data in SQL Server private void Btn_salvar_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(strConexao)) {…
-
1
votes2
answers57
viewsCount product output on day in mysql
I have an exit table of stock materials which is organized as follows I have products in stock every time I leave is released the number indicating the product id, the amount of output and the day,…
-
1
votes2
answers38
viewsQuery mysql bring last call without duplicate
Well, I have the following table: CREATE TABLE `chamado` ( `id` int(11) NOT NULL, `nomechamado` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `tipochamado` varchar(25) COLLATE utf8_unicode_ci NOT…
-
1
votes1
answer193
viewsHow to read position information that Cursor is in SQL Server
In the Cursor examples I found, to read the information I have to use the command: FETCH NEXT FROM In my code it’s like this: FETCH NEXT FROM CURSOR1 INTO @NAME - at the line Cursor is on I assign…