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
answer1061
viewsHow to get LAST_INSERT_ID() from a mysqli_multi_query() function with SET and INSERT?
this is my 'Betting Signup Method' on my betting system. In this way, I register data in two tables, a call BET and another BET_MATCHES, the system is controlled by time, so in all entries I need to…
-
0
votes1
answer93
viewsUse an sql class. Connection for each task or just a globally referenced one?
I have a class that is responsible for verifying the user’s account and password when logging in, and in the future I will need to implement another class to get other data in the database and…
-
0
votes1
answer209
viewsCase for several fields
I can make a query using 1 case to various fields? The fields are of the type int. If not, I can do it in php? Query select *, (case (pergunta1,pergunta2) when 1 then 'Ótimo' when 2 then 'Bom' when…
-
0
votes1
answer84
viewsCreate user using a Function
someone could help me, she keeps giving error when saved '-' Error(19,5): PLS-00103: Encountered the Symbol "CREATE" when expecting one of the following: ( start case declare quit for goto if loop…
-
0
votes1
answer181
viewsMYSQL: Find subsequences in a sequence and group by ID
I have a table with the following result: ------------------ |seq | ID | ------------------ | 1 | 12345 | | 2 | 12345 | | 3 | 12345 | | 4 | 12345 | | 8 | 12345 | | 9 | 54321 | | 10 | 54321 | | 11 |…
-
0
votes1
answer29
viewsmake Rows link in php
Good evening, I have a database and in it two columns, one of Links and the other of names, these links are to pages with more information about the film, and the column name contains the names of…
-
0
votes0
answers132
viewsHow do I get the largest value with the longest length in mysql in order by desc?
I have a sequence of values, for example: w1-16 w2-16 w3-16 w4-16 w5-16 w6-16 w7-16 w8-16 w9-16 w10-16 w11-16 So on and so forth. I made a query that takes the correct sequence as above. Example:…
sqlasked 8 years ago carlos dornelles 1 -
0
votes1
answer59
viewsError in UPDATE function
I am having this error while trying to run this update: Fatal error: Uncaught Exception 'Pdoexception' with message 'SQLSTATE[42000]: Syntax error or access Violation: 1064 You have an error in your…
-
0
votes0
answers41
viewsinsert and update date values in DB using a makedtextbox C#
Hello, while I was developing a system to manage the records in DB error is happening that when entering the values the data records become empty and when trying to update the information listing it…
-
0
votes1
answer919
viewsSELECT with REGEXP
next, I have a table of people: [name, license plate, Cpf] What happens is, some people who have the "same" Cpf have different enrollments. [Same] is in quotes, because in the database, there are…
-
0
votes0
answers58
viewsData Conversion
I am making a program and I would like to know how to save a field that contains only characters, but send to the bank only your code? I am using two tables to save the data and the field I want to…
-
0
votes1
answer1179
viewsQuery between different databases in SQL Server
Given this query: SELECT PontoSecullum4.DBO.funcionarios.N_FOLHA, PontoSecullum4.DBO.funcionarios.NOME, PontoSecullum4.DBO.funcionarios.EMPRESA_ID, 1 [ORIGEM] FROM PontoSecullum4.DBO.funcionarios…
-
0
votes1
answer422
viewsRepeated data with GROUP_CONCAT
I have a problem when I make one SELECT in my comic book, I’m using GROUP_CONCAT to concatenate the column of phones and email but I’m picking up repeated data. Here is the SELECT: SELECT…
-
0
votes2
answers65
viewsTwo Results in a Query
I have the following example, two related tables Tabela SETOR SetorID [chave] Setor Vagas Tabela FUNCIONARIOS FuncionarioID[chave] SetorID[chave estrangeira] Nome Funcao CargaHoraria I would like to…
sqlasked 7 years, 12 months ago Erison Nicodemos 99 -
0
votes0
answers47
viewsSQL search result in table on front-end
Guys, I’m developing a project for the college and wanted to put the result of the search made in mysql database in a table on the front end, however I’m having difficulties to do this, there is…
-
0
votes1
answer41
viewsDoubt when changing fields automatically subSelect
I would like to know how I do to change all fields of my sales chart. Modifying the full preco_field that will receive the quantity * preco_unitario. Remembering that I have 150 records in my sales…
-
0
votes2
answers365
viewsHow to change the format of a query result?
I would like to know if there is any argument in select that changes the format of result to be used as dump. Example: create table `table_name` (`id` int, `value` text); insert into `table_name`…
-
0
votes0
answers105
viewsStreamline SQL Query with Datatables
The query below returns a DataTables with approximately 400 database items Mysql. The difficulty is to return these values faster. Currently it takes on average 70 seconds to fully display the list.…
-
0
votes2
answers597
viewsMany to many ratio between various tables
I know that between two tables in a ratio of many to many 'we need' (not mandatory, but facilitates) a third table pivot which is what conventionally relates the ids of one with the ids of the…
-
0
votes1
answer111
viewsWhat was the error in the last UPDATE use line in Mysql?
I developed a final project without error, done in Java, but still have only one error UPDATE in the last row of table creation clientes database in Mysql language. I am asking to update the…
-
0
votes1
answer356
viewsReturn inserted value after INSERT
I have a following table: CREATE TABLE tblUser ( id INTEGER PRIMARY KEY AUTOINCREMENT, uuid VARCHAR(24) NULL, name VARCHAR(256) NULL } I’m inserting a uuid random to be a unique identifier directly…
-
0
votes0
answers111
viewsHow do I place the data of a php form in a Heidisql table
I have a contact form at php, when we submit an email with the entered data. What I wanted was to insert this data into a table in the program Heidisql. Form code: <div class="pagina"…
-
0
votes1
answer38
viewsHelp with Mysql SQL Query
I need to select All messages sent by user 1 to user 2 and know the messages sent from user 2 to user 1. I am unable to mount the SQL query for the situation described. Message table: IdMsg,…
-
0
votes0
answers26
viewsSending to the database a series of data accumulated during the day, is it possible?
I came to a question, to store data of events and browsing that the user performs on the site, would it be possible to only send to the bank after the end of the day, the actions that users have…
-
0
votes2
answers130
viewsError with AUTO_INCREMENT ID
My problem is to leave the first INSERT field empty,(if I fill the program runs), in my phpmyadmin the ID field is AUTO_INCREMENT, but without modifying that part of the code, it stopped. Code: $sql…
-
0
votes1
answer1147
views#1115 - Unknown Character Sep: 'utf8mb4'
When migrating the MAMP database to the server Are you making this mistake? Can you help me? Error SQL command: /*!40101 SET NAMES utf8mb4 */; Mysql message: #1115 - Unknown character set: 'utf8mb4'…
sqlasked 7 years, 11 months ago Jorge Santos 13 -
0
votes0
answers154
viewsDoubt in Binario Mysql Tree
Considering the tree below, I have a doubt. A B c D E F G H I J K So, I wanted to know if there is or has been any way to make a SELECT, where I bring all the IDS that are left of A. Because getting…
-
0
votes2
answers993
viewsShow SQLITE data between dates - Android Studio (think be between)
Good, I want the user to choose the data to show between the dates he chooses. I’ve tried everything but still can’t. That is what I want to filter between dates, but the user has to choose them. I…
-
0
votes3
answers406
viewsInsert decimal variable in Firebird
I am making an Insert in Firebird database in a Value field (decimal), but no decimals appear in the table. Code in C# : public decimal ValorUnitario { get; set; } produto.ValorUnitario =…
-
0
votes0
answers36
viewsSQL DATE EXECUTION - ODBC
I am doubtful in the date format that ODBC performs. I tried every way and nothing. This Query performs normal if I insert only the code, but when I want to enter dates it does not execute. I…
-
0
votes1
answer86
viewsProblems in generating a table
I’m having a hard time making a table. Could someone make a table that shows the times an employee made during the month? the idea would be to show the employee beats during the month. In my bank…
-
0
votes1
answer264
viewsInsert same data into two Mysql columns
Hello! I have a table with the name tabx and two columns y and z, when I insert the values in the column y I need a Trigger to copy this value to the column z. I have tried some solutions but…
-
0
votes0
answers86
viewsSQL-Count for each id
I want to show all student table records - name and number - and then in the right column, show attendance percentage. Let’s see: SELECT nome, numero, ( ( SELECT COUNT(aluno.numero) FROM aluno JOIN…
-
0
votes2
answers945
viewsCompare values with different conditionals in the same table
When making a SELECT COUNT(*) in the view vwNotaFiscal I get the total of lines: 3498 SELECT COUNT(*) FROM dbo.vwNotaFiscal WHERE tbEmbarques_emissao BETWEEN CONVERT(DATE,'01/05/2016',103) AND…
-
0
votes1
answer53
viewsAdd a SET list value to Mysql
I want to add values in a list (values separated by "," which will then be used the "split" function) in mysql, I am using this code: UPDATE clans SET Admins = concat(Admins, ',', 'NomeDoJogador')…
-
0
votes1
answer81
viewsAdvanced SQL query with dates
I have been in trouble for days. I have my chart and need to count how many grades are late, so that’s okay. I just don’t know how to make that appointment. I need to check if they are late, to be…
-
0
votes2
answers207
viewsSearch multiple tables at once
Colleagues. I need to search several tables ( a total of 28 ) where each table corresponds to a state of Brazil. This search would be the zip code, which is one of the fields of these tables. Inner…
-
0
votes1
answer917
viewsSearch by string in SQL/ PHP database
Good night, I have the following select which is to fetch users according to their category: $consulta = "SELECT * FROM app_usuarios WHERE cat = '$categ' $categ is the variable I receive dynamically…
-
0
votes1
answer759
viewsSql Query, fetch data from given ID
how to make a query, searching data from the given ID? For example, my table has 1 thousand records, I want to determine in a foreach the search of the data from the record 300.
-
0
votes2
answers2106
viewsFilter date by hour intervals to the last possible time within the same day
The rule All records that are within a 1 hour interval should be counted as 1 records only. Dice ID DATA 1 06/07/2017 09:20:35 2 06/07/2017 10:20:35 3 06/07/2017 10:25:30 4 06/07/2017 10:40:35 5…
-
0
votes1
answer128
viewsComplex SELECT with five+ tables
You guys, good night. I am developing a search system, and the query should be performed IN ALL existing tables. It turns out that for each type of result there is a presentation, for example:…
-
0
votes1
answer47
viewsDoubt in consultation with Entityframework
how do I consult with EntityFramework? with lambda or linq SELECT t0051_id_medicamento, t0100_lote, SUM(t0100_qtde) FROM t0100_historico GROUP BY t0051_id_medicamento, t0100_lote;…
-
0
votes1
answer549
viewsQuery with date and time in sql server
I have a field in the "char" type bank, I am returning the dates this way: select CONVERT(VARCHAR(20),HORA_FECHAMENTO) as HORA_FECHAMENTO, CONVERT(VARCHAR(20), DATEADD(hour, +0, getdate()), 120) as…
-
0
votes1
answer41
viewsDOUBT IN A SELECT - SQL
I basically have these relationships: I would like to take the value of the attribute "im_fab_template" of the table "tblImpressora" the code of the attribute "is_cod_printer" of the table…
-
0
votes1
answer20
viewsXtragridview - Where with variable
Everybody good night, how are you? I’m creating a user registration screen, where every user has an ID, on this screen, I have an xtragridview, which carries some address information. However, in…
-
0
votes2
answers1198
viewsRun query sql
$sql = "exec atualizar_feira '".$nome."', '".$endereco."', '".$cep."', '".$escolaridade."', '".$instituicao."', '".$telefone."', '".$email."', '".$aluno_cairu."', '".$curso."', '".$curso2."',…
-
0
votes1
answer72
viewsDoubt with select in mysql
Well I have the following tables: Requests id id_cliente id_vendador 1 10 20 2 10 30 3 10 20 Devotions Id data id_pedido 1 2017/01/01 3 I need to make a ? select' informing the ? id' of the order…
-
0
votes1
answer471
viewsTransfer data from SQL Server to Sqlite with Android
I have a software that is connected to an SQL Server database, but now I am making the software on Android using Sqlite. I need to transfer the SQL Server database (with the data) to my Sqlite.…
-
0
votes0
answers24
viewsA product reference various sizes in the database. How to do?
Hello! I am developing a Java system with Postgresql, and now I have reached a stage where I am with a great difficulty. I have three tables that need to relate, are they: Product: code,…
-
0
votes2
answers591
viewsSend SMS by PHP
I have a SMS gateway that receives data from my form in this pattern: <?php include "smsGateway.php"; $smsGateway = new SmsGateway('[email protected]', 'password'); $deviceID = 1; $numbers =…