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
answer40
views -
-1
votes0
answers8
views0x800B010C error on SQL Server Mananger Studio installation
I downloaded the SSMS on https://docs.microsoft.com/pt-br/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15 when I ran it returned me the message "INSTALLATION FAILURE…
-
-1
votes0
answers14
viewsHow to convert a decimal number into an integer in an SQL query
I am making a query in SQL in my database and is returning values in decimal. Is there a function to round the values or turn them into integers?
-
-1
votes0
answers30
viewsSQL - Return the result from a percentage
I need to increment in the command below, where it is possible to return a result bringing only a.2PRECO_CUST different (<>) from a1.PRECOUNIT when the difference is above 30% between these…
sqlasked 3 years, 2 months ago Josias Amorim 1 -
-1
votes0
answers37
viewsError SQL Syntax
I’m trying to edit a table in my database and create a fk Query: ALTER TABLE `tcc`.`usuarios` ADD INDEX `fk_playlist_idx` (`id_playlist` ASC) VISIBLE; ALTER TABLE `tcc`.`usuarios` ADD CONSTRAINT…
-
-1
votes1
answer41
viewsUnion Junction Operator
I need to present the departments that had stock movement in Feb/2018 and those that had in Mar/2018. I need to use a union operator to show the results of the two queries each of them returning the…
-
-1
votes1
answer452
viewsC#hash encryption
I was able to create a registration with an encrypted password, but in the access method (login) I have doubts on how to take the password typed and compare with the password registered with…
-
-1
votes3
answers220
viewsSelect multiple tables at the same time in SQL
I have 5 tables in my system: pacientes - Primary key idPacientes anamnese - foreggin key idPacientes avaliacoes - foreggin key idPacientes intervencao - foreggin key idPacientes contrato - foreggin…
sqlasked 6 years ago Pedro Lukas 21 -
-1
votes2
answers51
viewsSearch for elements with a certain distance of time (informing only time)
Detail sqlserver(2008) Good evening, I have the following problem. I tried to search all day and found nothing. -I need to search for elements in the same table that have the same date (day, time…
-
-1
votes2
answers51
viewsSort table values by Day and Month
I have this Select below: SELECT b.id, b.codigo, a.codacesso, a.seqproduto, a.desccompleta, b.quantidade, b.data_vencimento, b.data_atual, b.observacao, b.usuario, b.estado, b.loja, a.medvdiageral,…
-
-1
votes1
answer71
viewsSQL group records by time
I have a table in Mysql that stores events by time with the following structure: id / num_veh / time I would like to create an SQL query that returns events in groups by time range . For example:…
-
-1
votes1
answer125
viewsExcel generated by PHP query returns with incorrect characters
I made a PHP query to generate an Excel report. The values are recorded correctly, as shown below: However the generated Excel returns with incorrect characters, mainly in Mandarin, rsrs, as shown…
-
-1
votes2
answers1029
viewsConsult two tables without foreign key and relationship
I have two tables tb_pedido and tb_pagamento, put an example below with some dummy data. I need a report that shows the data of tb_pedido and of tb_pagamento, all in a single table as in example 3.…
-
-1
votes2
answers501
viewsIs it possible to run 2 queries at the same time in Mysql? Stored Procedure
I need to create a stored procedure to update the salaries of employees who earn less than 1000 and give a 10% increase. Other employees (who earn over 1000) will have 15% reduction. I did the…
-
-1
votes2
answers542
viewsInsert multiple records into Mysql using NODEJS
How do I add multiple records at once in Mysql by passing an array of, for example, products? HTTP-POST request, where products is an array with an x number of products. FRONT-END…
-
-1
votes1
answer1299
viewsProcedure in Mysql to clone products, Using CURSOR FOR SELECT
I need to clone the data from an EST_PROD_PRECO_CUSTO_EMPRESA table of id x company for the same table but of the company with id y. in Pl/Sql I did so. DECLARE CURSOR v_precos IS SELECT ID_PRODUTO,…
-
-1
votes1
answer119
viewsSQL SCRIPT WITH ERROR
Out of curiosity I took a report from my second semester of ADS and this course consists in making an SQL script based on 3 tables: ALUNO, CLASSE, MATRICULA. I made the script according to the…
-
-1
votes2
answers426
viewsView multiple records within one in Mysql
I have a question as to the mounting of a select. I have 3 tables that relate M:N as follows: Currently I am using this sql: select p.descricao, (select descricao from item where item.codigo =…
-
-1
votes1
answer52
viewsLARAVEL: Checking for SQL returns
I’m in need of some help! I have an SQL query in Laravel as follows: $cliente = DB::table('clientes')->where(DB::raw("cpf = '$cpf' AND (REPLACE(REPLACE(REPLACE(REPLACE(telefone1_num, '(', ''),…
-
-1
votes1
answer37
viewsSQL problem
I need to create an SQL that shows the registration numbers of employees of a table, their names and the number of people dependent on employees who have more than one dependent, ordering the result…
-
-1
votes3
answers72
viewsCode reduction in sql query
I created a query with the following objective: Select all the tools which the inventories theirs nay are gifts in all businesses. One Tool has one or more stocks, a stockpile belongs to only one…
-
-1
votes1
answer184
viewsCan you help me?
I am with a project to be done, the project itself consists of creating an sql script based on entity model and relationship, the booklet itself is not very well formulated and based on what I…
-
-1
votes2
answers70
viewsSQL + Medium Query
Gentlemen, I have an appointment that makes the calculation by line. The result is in the field calculo_diff. Calculation is the difference DataHoraTerno,as shown below: Now I need to make an…
-
-1
votes1
answer198
viewsSub query between two mysql tables, for each row a set
It is the following I have a table in mysql in which it keeps the name of the students and in this same table it has a column that keeps the code of the class in which the student is enrolled, I…
-
-1
votes1
answer60
viewsJOIN - Beginner’s Question
I have a question about full outer join, I researched and still do not understand. The last figure below explains, graphically, the operation of full outer join, that returns only the data not…
-
-1
votes1
answer114
viewsSQL MIXING EVERYTHING
I have the following query above as per the image. Why is she mixing the fields? SELECT celulasreunioes.idCelula, celulas.nome, celulas.idRede, redes.nome, celulas.idRegiao, regioes.nome,…
-
-1
votes1
answer9028
viewsNo connection can be made because the target machine actively refused them. XAMPP
Guys, I’m having trouble getting other machines to connect to my localhost, and the error always occurs: Warning: mysqli_connect(): (HY000/2002): No connection to be made because the hand of destiny…
-
-1
votes3
answers2084
views -
-1
votes1
answer962
viewsHow to compare two Python data frames
Hello guys I am trying to automate a loading process with python bringing data from sql and sending to a mysql table and I am facing some problems. Problem: I need that when I have new data in my…
-
-1
votes1
answer76
viewsHow to perform an Insert from a select in a table of another PHP database
I have two databases and I have a table Table in the database Servor1 no data and another database Server2 with a table Tabelay. And I want to make one select on the table Tabelay and with your data…
-
-1
votes1
answer26
viewssyntax error in login system - PHP
ERROR: Parse error: syntax error, Unexpected '$email' (T_VARIABLE) in C: xampp htdocs SUPPORT password.php on line 6 CODE: <?php session_start(); include("config/config.php") $email = $mysqli…
-
-1
votes3
answers750
viewsSQL Inner Join 3 tables
Good afternoon. I want to make an Internet but the result does not come out. Tabela1 = rec Campo = chvbfj(3) <- codigo do cliente Tabela1 = rec Campo = doc(3,4,5) <- lista de codigos de itens…
-
-1
votes2
answers158
viewsSELECT COUNT with low performance in mysql
I use a query within PHP to display the list of related categories and subcategories, get back more than 10,000 results (right) in 3 seconds on average, but after I implemented a subquery to check…
-
-1
votes2
answers64
viewsI’m getting two errors when I try to search by name in a product table
I’m scheduling a product management page, and I want to include a search engine to give users a search engine that can save time while they’re looking for the desired product, but after following a…
-
-1
votes1
answer47
viewsHow to rank the most useful comments from a table?
A following scenario: Each Product has a comment, each comment will receive a like to inform if it was useful (it is optional to inform if you liked the comment) I have a table called Customerreview…
-
-1
votes1
answer60
viewsSend data from a form by email
My goal is to create a contact form, where the user entered his name, email and message. The moment you clicked on "send message" I, being an administrator, would receive an email, with the user’s…
-
-1
votes1
answer58
viewsRemoval of repeated values between two tables with VBA
I need help with the elimination of equal values between two tables. I have two tables with several different fields, they have a common field called cellular, one table has the number in the format…
-
-1
votes1
answer29
viewsPHP - Getting user information through $_GET
Hello, I have a leaderboard on which I want to make sure that when I click on the player’s nick to open the profile containing his information, however, I don’t know exactly how to start. I’m trying…
-
-1
votes3
answers240
viewsView does not appear in query - Sql Server
I have a 2-field view that does not appear in the query window. When I add 3 more fields, it appears. What can be?. View: SELECT B.TX_LOGIN, COUNT(A.CD_PROCESSO) AS TOTAL FROM dbo.TB_DUE_CAPA AS A…
-
-1
votes1
answer98
viewsGo to the next row of a table with while. Is it possible?
I wonder if without a cursor, I have how to scroll through a table within a While. Example, I have this block: SET @CONT = 0 WHILE @cont < 3 BEGIN EXEC GP_ImprimeConsProdutosTipo ' and…
-
-1
votes1
answer55
viewsSum of values of a column in PHP
I am trying to add the results of an SQL column, but it does not return anything in my function. Here you have a function that returns all the data in the table registros and the function that…
-
-1
votes3
answers40
viewsSQL - Last Registration of each car
Hello. I’m consulting a BD where it returns various data from various cars, which are collected by a hardware installed on these. The hardware sends the data every x seconds. Soon each car has…
sqlasked 5 years, 5 months ago Gabriel N Silva 3 -
-1
votes1
answer61
viewsCommand in SQL already with correct calculation
We have a differential in the payment of ICMS and I would like to export a spreadsheet which I have already created the command, also create what amount we will pay from ICMS. In case it would be…
sqlasked 5 years, 5 months ago Brian Benigno 1 -
-1
votes1
answer1691
viewsConvert LONG column to VARCHAR2 in ORACLE - problem related to LONG column value size relative to VARCHAR2
CREATE OR REPLACE FUNCTION PRC_HAM_CONVT_LONG_VARCHAR2 ( p_owner VARCHAR2, p_tabela VARCHAR2, p_coluna VARCHAR2, p_rowid UROWID )RETURN VARCHAR2 IS v_cursor INTEGER; --cursor v_length INTEGER;…
-
-1
votes1
answer88
viewsPopular table using two that has no link
Guys I’m having a little problem I have the following situation: table escritorio where I have a field called id that I’m gonna need table etapas where I have the fields id that I’m gonna need; I…
-
-1
votes1
answer102
views'Incorrect datetime value[...]' when using bindParam or bindValue
I am trying to enter a register in the database as follows (PHP) $sql = "INSERT INTO `tb_teste` (`estrutura`, `foto`, `data_cadastro`) VALUES (':estrutura', ':foto', ':data_cadastro')"; $sql =…
-
-1
votes1
answer426
viewsHow to create a product via SQL in Woocommerce
I am creating a snippet to add a product in wordpress. But I realized that it is not enough to insert the product in the wp_posts table. The query works, the item is inserted in the database, but…
-
-1
votes2
answers73
viewsCalculating balance and separation by currency
I am in need of help to do a function that I can know the balance of customers' invoices and that the value is separated by coins of invoices (for example 250 USD | 340 EUR) because there are…
-
-1
votes1
answer155
viewsHow to update a database (Sqlite DB) using the Workmanager library?
I am using the workmanager library to show a notification to the user indicating the time to take his medicine. I am also using the Sqlitedatabase library to store medicine information such as:…
-
-1
votes2
answers193
viewsSQL Compare values in other rows
I have a table called transferencia that has data on the movement of a guest in a hotel, for example The table has no date of departure, so the date of departure is the data_entrada in which the…