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
answer33
viewsRead array from a field
in an sql query, it returns me this value 10,30,40,50 of the fields" mark_ups_range" How to read and quabrar in lines this values? exemology 10 30 40 50 $sql1 = "SELECT mark_ups_range FROM…
-
0
votes0
answers37
viewsOFFSET does not work on SQL Server
I developed the sql side paging in my SQL Server 2014, when I played in production gave the problem with the OFFSET because the server has sql 2008. I tried to implement otherwise but did not…
-
0
votes1
answer4475
viewsMysql error : #1265 - Truncated data for 'value' column in row 1
Good afternoon, you guys. I gave the following command in Mysql: UPDATE procedimentos SET valor = '2.400.00' WHERE procedimentos.id_proced = 1 the value field is a double, I’ve tried with float and…
-
0
votes1
answer150
viewsExercise involving Function in Postgresql
The question would be as follows: With the following Bank: Telefone (id, numero, operadora_id) Cliente (id, cpf, nome, rg, sexo, uf) Operadora (id, nome, cnpj) Contrato(id, cliente_id, telefone_id,…
-
0
votes1
answer47
viewsI need to take the patient id from the table to the next page, along with the user, by clicking the button
<?php $conexao = new mysqli("localhost","root","","hospital"); if($conexao->connect_errno){ echo"Failed to connect to MySQL: (" . $conexao->connect_errno .") " . $conexao->connect_error;…
-
0
votes2
answers663
viewsLeft Join or Sub-Select? which one has the best performance?
I’m studying which one of the fairs below would perform better. So I wrote them both and ran them in the same database with the same data: Query 1: select a.numeroOp as OP, a.codigo as CÓDIGO,…
-
0
votes2
answers2099
viewsHow to export an SQL table to a . txt file?
good morning! I need to insert the return data of a Select into a file . txt containing the column names and separating the data by ";" How can I do this process? Grateful From Now…
-
0
votes1
answer2255
viewsHow to select two tables in mysql?
I know this must be an easy question, but I’m a beginner: I have these 3 tables in my bank: In this case, the purchased table is where the user’s Cpf is stored that acquired the course and saves the…
-
0
votes1
answer538
viewsView Java Database Values
I’m a beginner in Java and I’m making a mini RPG-style program for Database Testing, and I want to display the data contained in the BD using a ArrayList, but the result of the exhibition is always…
-
0
votes3
answers127
viewsSelect dates less than a given year
How can I create select to show only employees of a company who have been admitted to it before a certain year ? The type anoAdmissao is date ie: dd-mm-AA…
-
0
votes3
answers381
viewsHow to select the year in PLSQL?
I have a chart of company employees. Must show who completed a year of work at the company. The data type for the field Information: DATE (dd/mm/YY)…
-
0
votes1
answer229
viewsRange defined by SQL user
In sql there is some way to define the range of a query according to the user’s past ? Example Number of days the user enters for 7, and set as registration date day 07/01/2018, the bank return the…
-
0
votes1
answer234
viewsError running SQL "Create Trigger..." inside a C#application
Goal: Run a create Trigger script using a string within C#. Problem1: Table not found (because the script does not indicate in which Table to create Trigger). Tentative2: Start string with "Create…
-
0
votes2
answers119
viewsQuery sql SELECT
Which command select shows me only those comments from a single user? For example: I have a table Post where it stores the comments of each user (usuario_1, usuario_2, usuario_3), but would like to…
sqlasked 6 years, 9 months ago Raphael Shembek 49 -
0
votes1
answer299
viewsHow to select multiple data from related tables
I created three tables in the student database, book and loan, I would like to list all the books that were loaned to each student, however, when the student borrows more than one book the command I…
-
0
votes1
answer1338
viewsMysql Database (Insert Into and correct order)
my doubt may seem silly, but it is something that I always get lost, how to know the correct order of Insert into (to insert data in the table) in the database ? I was told it’s for the foreign…
-
0
votes0
answers235
viewsHow to do an exclusive specialization in sql?
Well, I finished the entity relationship diagram of the database I’m creating and in it there is a service entity, which has two exclusionary specializations (one or the other, can’t be both),…
-
0
votes2
answers600
viewsRecover image in SQL SERVER and put in a REPEATER list
Today I recover information from a database and I list in a REPEATER, until then all blz. But I also need to take an image from the database and show on this REPEATER. Follow below as I show the…
-
0
votes0
answers338
viewsJoin querys using Outer apply
I have these three querys, and I want to put them together using the outer apply. How can I do that? SELECT SR1.COMPANY, SR1.FILIAL, SR1.DOC, SR1.SERIE, SR1.LOCAL, SR1.TIPONF, SR1.CLIFOR,…
-
0
votes0
answers27
viewsHRESULT:0x80020003 error in sql server
I am working with a Sql server database and it started to present a strange error, preventing me from accessing the design and creating new Tables. I looked on the Internet and I couldn’t fix that…
-
0
votes1
answer350
viewsCondition and loop within a function
I am creating a function to exit the stock, where v_saldo_item_peps is a function that returns a table, with the items that have balance, in their respective entries. I need to check whether…
-
0
votes0
answers172
viewsAdd column to SQL considering some conditions to be valid
I’m trying to gather two pieces of information and I’m not getting it. I set up this SQL to bring me only the products that were purchased that had a discount through a contract. However this…
-
0
votes1
answer260
viewsRun select + update SQL query
I have the following SQL: SELECT prospect.uni_id, prospect.usu_id, prospect.pro_nome, prospect_agendamento.* FROM prospect_agendamento JOIN prospect…
sqlasked 6 years, 9 months ago Sr. André Baill 6,946 -
0
votes0
answers46
viewsGenerate random characters in SQL
Hello, I have a question in PHP My Admin which is as follows: -I have a table that I need to put as default value in a column a random value. Someone could shed some light on this matter? I know how…
-
0
votes1
answer126
viewsGroup by error of a query in db2 SQL
The Consultation: Select ITEMNFS.Recnum, ITEMNFS.ITEM, sum(ITEMNFS.VL_TOTAL), sum(ITEMNFS.QTDE_FATUR), ITEM.PER_IPI from ITEMNFS inner join ITEM on ITEMNFS.ITEM = ITEM.ITEM inner join NFS on…
-
0
votes1
answer1658
viewsRemove the last value found inside a string
I need to take an average of payment conditions in the database and I came across the situation where the condition column is a string and it can receive parcel values separated by bar. I need to…
-
0
votes2
answers33
viewsConcatenate data from a table
I have the following sql statement: SELECT a.alunonome AS aluno, m.materianome AS disciplina, AVG(CASE n.notabimestre WHEN 1 THEN n.nota ELSE null END) AS bim1, AVG(CASE n.notabimestre WHEN 2 THEN…
-
0
votes2
answers245
viewsError using a Static final String to build an SQL query
Good evening person, I’ve been searching around and I know that you can do CRUD organized... I know that the programmer creates a class with the strings, leaving for example public static final…
-
0
votes2
answers322
viewsFind lines of the last 24 hours that repeat the most (Mysql)
'SELECT `from`, `to`, count(*) AS num_clicks FROM my_rank WHERE my_rank_data BETWEEN "'.$yesterday.'" AND "'.$today.'" ORDER BY num_clicks DESC LIMIT 0,20'; Above I am trying to take the fields…
-
0
votes2
answers220
viewsSearch Dates with Difference Defined in SQL Server
How to perform a query in MICROSOFT SQL SERVER that before a defined number of days returns only the dates that meet this existing difference. for example In a table have the following registered…
-
0
votes1
answer79
viewsSQL code does not work wanted an explanation of why the code error?
I received these two tables in an exercise, but my code isn’t working and I was wondering if someone could explain it to me. I have to submit all orders created in the last 10 days. My code: Select…
sqlasked 6 years, 9 months ago Andre Junior 13 -
0
votes1
answer365
viewsHow to create an SQL function that calls a script in python?
I need to create a software that at each insertion in a table a python script detects that there has been a change in this table and execute certain commands. I have done an implementation that is…
-
0
votes1
answer64
viewsQuery return problem
I have a problem with my query return. public IList<Rota> Lista() { //* string hql = "SELECT * FROM Rota WHERE ORDER BY Km_Atual ASC"; string hql = "SELECT Km_Atual, MAX(DtLancamento) FROM…
-
0
votes0
answers26
viewsHow to add functionality to buttons
i am new to php, and I am making a site manager, with it I want to manipulate the database, I am listing the database data and each database item has three buttons to view; Edit, which will edit the…
-
0
votes1
answer59
viewsWhat is the utility of using Basecolumns. _ID to define a contract class in Sqlite?
Why should I wear Basecolumns. _ID instead of simply defining a string as _id ? For example, instead of using: public static final String _ID = BaseColumns._ID; Wouldn’t it be simpler to use this?…
-
0
votes1
answer201
viewsSelect case with expression and setting the Else result
Personal someone can help me with a select case problem, I need to make a select of an expression and if that expression gives a negative result, it shows me the value, if positive the value has to…
-
0
votes0
answers278
viewsPDO, Select a query with some fields, from a certain user and code
I need to set up a consultation where I’ll only have five fields (STATUS, ID_USUARIO, PACKED, ID_TRANSACAO and ENTREGUE). I need that when I have change of STATUS change to another table, and update…
-
0
votes1
answer38
viewsDoubt in SQL Performance
A question that has arisen now, and which I always see in one way or another in Sqls of procedures, is the following: NOT TABELA.CAMPO IS NULL or TABELA.CAMPO IS NOT NULL. What is the difference in…
sqlasked 6 years, 9 months ago Paulo R. F. Amorim 995 -
0
votes1
answer28
viewsWhy were views slow after migrating data via script in Firebird 2.5?
I’m working on a standardized database. I recently refactored her structure (A) by renaming all existing PK and FK, because they had the names that are automatically generated. When migrating data…
-
0
votes0
answers181
viewsHow to Update 2 tables with Switch case and database data and others coming from an xml return?
I have progressed a lot in the code, within what I thought was necessary, only I don’t know how to organize my syntax so that everything happens as I want, the switch/case that runs in the bank to…
-
0
votes1
answer51
viewsSQL query without repeated element
I have this query in sql SELECT "Certificates"."Email", "Organizations"."CommonName", "Certificates"."Id", "Certificates"."OrganizationId" FROM "Certificates" INNER JOIN "Organizations" ON…
sqlasked 6 years, 8 months ago Vinicius Macelai 364 -
0
votes1
answer42
viewsResult SQL statement
Hello! I have a table of a questionnaire, I would like to have a result grouped by "property", making a GROUP_CONCAT in the "answers", according to the model below: property | question | answers 10…
-
0
votes3
answers1947
viewsAdd time column in SQL SERVER
I got a column like team in a table. With records such as: 00:02:15 00:09:47 00:00:25 ... I need in mine select, find the sum of those minutes in format team. Return example: 00:12:27 I tried in…
-
0
votes0
answers80
viewsIdentify and list which users viewed an Laravel post
Good afternoon, for study purposes, I am creating a communication system, where users register communiqués on a timeline, but I came across the following question, How would I show which users…
-
0
votes2
answers2415
viewsSQL query that compares two tables and returns values
Work with a database using with DBMS Postgresql, where I need to compare tables, example: table_janeiro and table_February. I need to perform two consultations... first You must return the values…
-
0
votes2
answers9821
viewsSelect to display the column name of a table?
Tables col1| col2| col3| ...| coln 1 | 2 | 3 | ...| n Display the name : col1 col2 col3 ... coln…
-
0
votes1
answer184
viewsMYSQL average per minute
Hello, in the table below, you have to do a select that returns the following: select the average current per minute between day x and day y and on return display the day and minutes? I have a…
-
0
votes2
answers61
viewsMake a SQL language design that returns the number of clients who have no business done
I can not solve this issue, I want it to show number of customers without repeating primary key, no realized deals and show a warning if customers have done business. There was this mistake here.…
-
0
votes0
answers73
viewsMy select is not generating result
I’m doing a select , this same select tested in the database returns me the information I need , more in my code . net gives an error saying that it is not generating result what is it that I am…
-
0
votes2
answers798
viewsSum with Internet Oracle
Staff need a help, I need to create a report that shows the total quantity of each product in stock, but I can not make appear the name of the products, only the product code and the sum of the…