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
votes2
answers593
viewsphp-upload image and upload to database
I’m trying to insert an image into the database but when I click image upload, it gives the following error: Warning: getimagesize(): Filename cannot be Empty in…
-
0
votes1
answer204
viewsHow to do column operations where you give nicknames?
I have the following hypothetical consultation with the bank: SELECT dinheiro_na_carteira, (SELECT sum(despesas_pagas_carteira) FROM DESPESAS WHERE id = X ) as despesas FROM RECEITAS WHERE…
-
0
votes1
answer47
viewsProcedure does not return the full column
I created a project with the ibexpert, does the commit correctly, but at the time of turning the Procedure, get the bug: Multiple Rows in Singleton select. My intention is to list all values in the…
-
0
votes1
answer32
viewsphp/sql - phpmyadmin binary value show on web page
I have a database of books each book has its ISBN, title etc and even has an image, which I uploaded in the database for each book. but the problem is that the image does not appear, does the image…
-
0
votes1
answer59
viewsCondition(if) does not work for entering data
I did this query to insert data. I should only insert data if there is nothing in the OIT1980 table. Then I mounted a cursor and walked and put an IF. If I remove the IF, it works, but if I leave it…
-
0
votes1
answer39
viewsSQL query returns duplicated and error value
I have the following query but it is returning duplicate and wrong results. Arthur should show 0 and not 30.…
sqlasked 6 years, 11 months ago Diana Madeira 485 -
0
votes0
answers366
viewsPHP form data does not enter the database
Hello, I’m new in PHP and I’m doing a small scheduling page but I stuck in the input part of the data inside the database, below my codes: Index.php <html> <head> <title> Controle…
-
0
votes1
answer26
viewsWhat command do I use to put parameter in a list in sql?
I was performing a proof appeared a question saying to create a list in which the values were not greater than 6, I could not understand very well to do this.
sqlasked 6 years, 11 months ago rodrigox bragahz 59 -
0
votes1
answer73
viewsUpdate and maintain update code when it repeats
I did this update: declare @rx_num varchar(20), @id_oit_max int, @id_exm_rea int, @id_xfc_novo int, @id_xfc int = 0 declare oit_cur cursor for select pl.rx_num, er.id_exm_rea, er.id_xfc from…
-
0
votes2
answers1444
viewsSQL query taking dynamic Javascript field
You could make an sql query by picking a field typed by the user in a form and automatically filling in the result in other fields?
-
0
votes1
answer274
viewsWhy does MOD(11.2,2) give 1,2 and not 0?
I need to take the rest of a division in ORACLE and I am using MOD that works very well with integers but when using decimal numbers it is a problem. Ex : MOD(11,2) = 1 ok MOD(11.2,2) = 1.2 Wrong is…
-
0
votes0
answers275
viewsConvert NVARCHAR to NUMERIC
I have a table that has a VALUE column, but the column is in nvarchar, this column nvarchar does not let me do the correct formatting in the report I am using select. I can do the conversion in SQL…
-
0
votes1
answer40
viewsQuery where result equals any of the values in the list
I have a table of Duplicates that has the month reference as string,(ex: 01/2012, 05/2016 and etc) And I need to perform a query between a date range, if the field was Datetime I know it would be…
-
0
votes1
answer515
viewsChange column value in Firebird
I have a table with approximately 7 thousand records, I need to create a new column in this table but I would like all old records to have the value’S', when I try to create the column the fields…
-
0
votes0
answers998
viewsTake data from excel spreadsheet and insert into SQL SERVER database
I want to know if you have how to take the records of a spreadsheet and play for an SQL-SERVER table, there is this possibility ?
-
0
votes1
answer692
viewsChange column name "id" of an sql return
I want to conduct a consultation SQL and change the name of the columns in the result because I have 3 columns id. Currently my SQL this way: SELECT * FROM shopweb_tipo as st INNER JOIN…
sqlasked 6 years, 11 months ago Everton Figueiredo 520 -
0
votes0
answers436
viewsSelect with data from associative tables
I am creating a small database to store the books I own at home, but I came across the following situation: I have two associative tables, a call self-published, that allows the same book to have…
-
0
votes0
answers165
viewsInsert SQL Server Column does not receive value
I’m trying to get the Insert in a simple table, but a field of it, it’s not saving the value I’m passing it, and the weird thing is that all the other columns get it right. Example INSERT…
-
0
votes1
answer131
viewsSQL Report Builder 3.0 Merge Rows into a Totalizer column
Considering a simple query where you bring a list of people containing your name, code and age, I would like it to be displayed in the last right column the sum of the ages according to the image…
-
0
votes1
answer64
viewsHow to save the highest value of rowCount?
I want to save in a variable the highest value ever obtained by rowCount I just don’t know how to make the logic. Current consultation: $playeronline = $pdoG->prepare("SELECT login FROM u_hero…
-
0
votes1
answer58
viewsSQL Clause with Codigniter
Good morning guys to need to do an update in the database but I’m not getting below the codes: I am using the codeigniter so this the following way: Controler: function editar($ocod) { /* Aqui vamos…
-
0
votes0
answers69
viewsHow to compare php password to sql that was entered with PASSWORD
Enter the password with the PASSWORD argument in my example query. INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, PASSWORD(value2), value3, ...); I want to know if you have…
-
0
votes1
answer43
viewsStandard information of a record
I have a table [produto] and a table [produto_embalagem], which may contain several packages of a single product. The discussion is whether the standard product packaging should be a marking in the…
sqlasked 6 years, 11 months ago Ricardo Melo 3 -
0
votes1
answer330
viewsI cannot restore database in mysql
I am trying to restore a DBS I have on my machine, but unfortunately I am having problems... ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL…
-
0
votes0
answers353
viewsBulk Insert bringing information without accentuation
Expensive, Good Afternoon! I have a problem when I perform an excel Bulk Insert for Sqlserver, I have a column called city and when I do the Bulk Insert and include the information in the database…
-
0
votes2
answers104
viewsSql file or direct in the database
Today a question came to me, I was creating a table in the database and I found out if I should do it manually, directly in the database or create this table through queries, creating a page .sql.…
-
0
votes1
answer98
viewsQuery PIVOT or SUM
My consultation is as follows:: mysql> select product_id, presentation, price from Variant where product_id = "1604"; +------------+-------------------------+-------+ | product_id | presentation…
-
0
votes1
answer2083
viewsHow to sum the values of an SQL column
I need to make a system that takes the three biggest donors. My table: donate_ID | donate_NAME | donate_AMOUNT This donate_NAME can be repeated, and if this happens its value will be added with the…
-
0
votes1
answer169
viewsSort by day of the week and time
I want to sort by the day of the week and time the data are coming as follows: id, dia_hora 1 SEG-10h 2 QUI-11h 3 SEX-09h query that works when you receive only the acronyms with no time: SELECT…
sqlasked 6 years, 11 months ago Giovanni Dias 712 -
0
votes2
answers30
viewsPHP - allow only one area of the website to the user
I have a search bar that only registered people can access. So far so good my code is working, the problem with every search in the search bar credentials are requested, IE, my code always requires…
-
0
votes1
answer348
viewsUsing Case in Order By with Union
I’m having trouble using Order by com Case on Union, so it works: select tb_a.nr_rua, tb_a.cod_altura, tb_a.cod_posicao, tb_a.cod_lado where ...... union all select tb_b.nr_rua, tb_b.cod_altura,…
-
0
votes3
answers669
viewsField with Cedilla in Mysql
I have a field in my database table Mysql with the name 'description', with the special accents. My problem is this: When I make a INSERT INTO using directly the phpMyAdmin, it normally inserts the…
-
0
votes2
answers974
viewsList 3 tables in a row - MYSQL
I want to make a table together information from 3 tables. This table will be ordered by date (day/month/year Hours:Minutes) and visually speaking would look like this Table image For better…
-
0
votes0
answers58
viewsRegister in table if query returns result (Oracle)
I’m developing a call panel. I have a query that results in the client call (name/password/Guiche), this query shows the result for 10 seconds, after that it is empty until the next call. I need…
-
0
votes1
answer6479
viewsGenerate MER from a Database
I have a Database backup and for lack of documentation I need to generate his MER. I remember reading somewhere that there are programs that do this reverse engineering and generate the MER. Could…
-
0
votes1
answer192
viewsHow to properly configure & character in SQL Developer 17.3
Hello friends I am trying to make a sql query in SQL Developer as follows: SELECT * FROM CLIENTE WHERE NOME_CLIENTE IN ('SALES & CIA AGUIAR', 'SAO JOAO') The tool is understanding the character…
-
0
votes2
answers520
viewsGive a select to return the exclusive values
I have several repeated values, the value can have status (different or different) or I can have two values with different/different status, and I need to compare them (in case I use a key), that…
-
0
votes1
answer272
viewsError 1452 Mysql
I’m starting in mysql, so don’t notice the badly made tables. Finally I have the following tables: create table Alunos ( MAT int, nome varchar (45), endereco varchar (45), cidade varchar (45),…
-
0
votes1
answer262
viewsTruncate by ignoring the foreing key
Cannot truncate table 'ARITHMETIC.glo.tbEndereco' because it is being referenced by a FOREIGN KEY Constraint. Truncate has already been executed in the agency table that references the address that…
sqlasked 6 years, 11 months ago Ari Santos 361 -
0
votes1
answer94
viewsTaking data from a table from grades average of another table?
Tabela - lista id | nota 1 | 10 2 | 8 3 | 7 1 | 8 3 | 9 I want to average the notes of those who have the same ID, and for that I created the following query: SELECT AVG(nota) FROM lista GROUP BY id…
-
0
votes3
answers31
viewsDoes not work SQL
I have this SQL function in a php code but I’m not getting the data requested from the database $query_part = "SELECT * FROM participacao WHERE manutencao = 'Equipamento' AND 'Material de saude'…
-
0
votes1
answer46
viewsReturn average cost between partially equal products
As exemplified in SQL Fiddle, given the tables, the data will be returned as follows: nome | descricao| tipo | custo| ult_lancamento | entradas | saidas…
-
0
votes1
answer83
viewsHow to interpret * in this query
I got a query which, apparently, is simple if it weren’t for the fact that I have these two * Alas, I’m not sure if it’s inner join, left join or someone from the same family. I need to turn this…
-
0
votes1
answer123
viewsHow to find the most updated tuple in postgres?
Amigos. I am having difficulty recovering the most current mileage of a vehicle when it arrives at the company. The identification of the tuple is by the date of arrival of the vehicle in the…
-
0
votes2
answers770
viewsView ID in the form before registering php and mysql
I’m making a registration screen , only I wanted the system to already display the ID (id_entity) that will be registered. When saving, it will ask if I want to register documents, then if I click…
-
0
votes1
answer114
views"min()" with two parameters
The person who worked before me at the company made that code: MIN(DATEPART('weekday',[Entrega Data Real]),6) What this 6 means? A min() can have two parameters?…
-
0
votes1
answer2160
viewsHow to remove a SQL Server Constraint
I’m having a problem removing a Constraint from a table. Objective is to delete the Constraint to delete a table. The problem is: I have an Income table that is associated with Extra Income. This…
-
0
votes1
answer38
viewsError while restoring external database from Asp.net mvc application
I’m trying to restore a bank SQL that I created on a provider that does not have the option Webdeploy. And my goal is to boot a database using ASP.NET MVC with EntityFramework. Well, when you put…
-
0
votes0
answers285
viewsSum hours obtained through a query in mysql
SELECT TIMEDIFF( atendimento_ticket.close_atendimento, atendimento_ticket.open_atendimento ) AS duracao FROM atendimento_ticket WHERE id_tec =…
-
0
votes1
answer188
viewsCreate view by transforming deleting or transforming DATE into VARCHAR in ORACLE
I have a table with 58 different columns and would like to create a View treat the fields DATE as SWEEP, without me having to discriminate all the columns in the creation of View. CREATE VIEW…