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
answer51
viewsError creating Diagrams in Sqlserver Studio 2014
This week I had a problem creating diagrams in my database ( SQL Server 2014), it returned me an error message: Database Diagram support Objects cannot be installed because this database does not…
-
0
votes0
answers29
viewsDynamic space reserve
In other issues in Sopt, a question arose of those that generate doubts. About the type VARCHAR, that has dynamic space allocation as stored data, I ask: It’s different to use VARCHAR of VARCHAR(2)?…
-
0
votes1
answer73
viewsProblem with subquery
Good night, I need to bring the full subquery result: (select (valor * 0.05) from tbl_exames) as 'Valor dos Exames', In a delimiter: delimiter // create procedure comissao(idmedico int) begin select…
-
0
votes0
answers81
viewsChange Mysql query to work on SQL Server and Oracle
Would anyone know how this query in Mysql would look in SQL Server and Oracle? SELECT COUNT(*) AS TOTAL, SUM(EVENTO = 7 AND RESULTADO = 0) AS QTD_RX_OK, SUM(EVENTO = 7 AND RESULTADO <> 0) AS…
-
0
votes0
answers37
viewsRemove Fixed lenght from SQL Server
The string fields of the tables in my database are coming with Fixed length as true. So if the size is 60, and I save a string with a size of 30, it fills the string with spaces up to the full size.…
-
0
votes2
answers78
viewsWCF does not connect to Sqlserver when published on IIS
I am using WCF + Sqlserver, when running by Visual Studio works perfectly, when I publish and update on IIS an error occurs: "A network-Related or instance-specific error occurred while establishing…
-
0
votes1
answer170
viewsVery slow SQL query in Openedge database, what can it be?
I’m having trouble executing queries in the Openedge 11.6 database. Several queries take a long time to be executed, sometimes almost 2 minutes. Here’s an example of a query I’m trying to run:…
-
0
votes0
answers57
viewsProblems with Sqlitehelper
Hello, I have a registration project and I’m having trouble reading Sqlitehelper, the app only runs without it, when I try to use gives error, the app turns off, if anyone can help me find where is…
-
0
votes1
answer36
viewsSQL Database Log in Restoring Pending
I have an SQL database that was accessed by someone else and it entered "Restoring Pending" as soon as they accessed. Is there any way to extract some log or any other more detailed way to know how,…
-
0
votes1
answer235
viewsUpdate with select CTE Error
I am having difficulties to perform an update with select CTE. I want to update the charging field. Below is the query and just below is the update I tried to perform, but the following error…
-
0
votes1
answer753
viewsGo through array and check if a field is empty (PHP)
In one of the files I have a dynamic table that receives data from BD, but with the possibility of inserting more rows in the table. Note that when inserting more rows the idFaturacao will be empty.…
-
0
votes1
answer60
viewsMysql Cross Query
I’m not sure how much to express myself more than I need is how I can do a normal and reversed query. Below I have two fields one of origin and the other of destination. I need to make a $origem =…
-
0
votes3
answers1241
viewsStatement Where comparing Date(type date) variable with current date
Hello. I am using Oracle SQL and need a query that returns values where the date is equal to the current date. Oracle has some word reserved for current date in the system? My code: insert into…
-
0
votes1
answer36
viewsI cannot see the elements of a table row
I am trying to visualize elements of a row of a table of mine, only separately. And I have not been succeeding. Follows the code: <?php require_once("conexao.php"); $id = $_POST['idlicita'];…
-
0
votes1
answer36
viewsSQL - Changing Field Names within a Column
Good, I have a doubt, I have for example a column called "Categories" and within this column I have several fields (categories) and wanted to change the name of these fields. For example "category…
-
0
votes3
answers64
viewsDifficulty when mounting SQL query
Whoa, guys. I’m having difficulty to mount a query in Mysql. The thing is, I have a table with the following structure The time_orange and time_blue columns store system user ID’s. I need to search…
-
0
votes1
answer858
viewsConvert to decimal without adding zeros - SQL Server
I am converting a number from varchar to decimal. This number already has the boxes after the comma, and when I convert it adds 2 more zeros. Example: 12.345,67 ---> 1234567,00 The code I’m using…
-
0
votes1
answer425
viewsHow to set the time of a "timestamp" to 23:59:59 in postgresql?
I have in a cell that contains only the date, in case 2018-07-11, I need to make a select that will bring this cell so: 2018-07-11 23:59:59, it is possible to do this?…
-
0
votes2
answers269
viewsReturn last record from table
I’m trying to make a method that returns the last record of the table but gives error: Failure in operation"coditem" public int UltimoItem() { con = conexao.obterConexao(); try { cmd = new…
-
0
votes1
answer505
viewsSQL Server - Trigger does not run after a given field
I’ve got Trigger down: CREATE TRIGGER AtualizaDataAlteracaoSegmentos ON dbo.Segmentos AFTER INSERT,UPDATE AS BEGIN Begin tran update Segmentos set DataAlteracao = GETDATE() where Id = (select ID…
-
0
votes0
answers51
viewsGenerate sql script on a given date
Good afternoon! Guys, I have a big mission here. I have a script that I assembled below that I need it to be executed only on the 1st of each month respecting the two conditions I put in the IF…
-
0
votes1
answer295
viewsProblems connecting Postgres with java
Well, I’m having a problem connecting my java application to my database (I’m using pgAdmin4 which is basically postgres). Java code: public class ConnectionFactory { private static final String…
-
0
votes1
answer685
viewsHow to transfer data from one table to another on different servers
I need to copy the records of a table that is in a Linked Mysql server to SQL Server, that is, transfer the records from one server to the other. Could someone tell me a way to perform this through…
-
0
votes2
answers153
viewsError while displaying array in PHP
I have this array in PHP and I must display the users name and email field. But php display an error message: array(4) { [0]=> object(stdClass)#25 (5) { ["idusuario"]=> string(1) "2"…
-
0
votes0
answers319
viewsAccentuation with Multipart/form-data form and sql server using ajax
Hello. I have a problem that’s keeping me up at night. I am working on legacy code in classic Asp and need to register a form that contains pdf file and data (such as name, surname) and other…
-
0
votes0
answers33
viewsAutomate table fill
I have a table with the following structure: id - email - key_de_active I need to popular the key_de_active column with a random key (I already have the script to create this key), only it’s like,…
-
0
votes1
answer82
viewsMerge the results of two SQL’s commands into H2
I created the following Query: SELECT s FROM SuprimentosPedidos s WHERE s.codigoModeloImpressora = :codigoModeloImpressora AND s.codigoEmpresa = :codigoEmpresa and s.prioridadeSaida = 1 ORDER BY…
-
0
votes0
answers38
viewsUse of SQL Database without external programs
There is some way to make an application, install a database on a person’s computer, and on that computer use a database without using SQL server or anything like that, only the application is…
sqlasked 6 years, 4 months ago Tiago Cerqueira 1 -
0
votes2
answers102
viewsHow to take the last inserted values from two tables, and sort them by the last access?
I need to create a select who picks up the id's of two tables, unite them and show me the last record of the two together. I tried so: SELECT DISTINCT p.cod_mobilibus, p.nome, q.dt_acesso FROM…
-
0
votes1
answer69
viewsPostgresql/Visualstudio database modeling
Hello. I have this form: How much the modeling of the bank there in the part of "products" I intend to load all products(name, quantity available, unit value) and when the person selects some and…
-
0
votes1
answer56
viewsError when registering in the form
When you select the value and I will register informs me an error. System.Argumentexception: The value "System.Object[]" is not of type "Blogweb.Models.Compra" and cannot be used in this Generic…
-
0
votes3
answers285
viewsPHP + SQL Add two values from the same column
I have a table like this: And I need to add the value of id 1 to the value of id 15, saving to a variable in PHP. I’ve researched a lot but I couldn’t get anything specific to it. Thanks for any…
-
0
votes1
answer41
viewsUser connection location in Mysql or Mariadb
It is recommended that I change a user’s connection location from the table mysql.user? For example, I create a user 'danilo'@'localhost' but then I want it to connect from any machine, there’s…
-
0
votes2
answers436
viewsSelect subtraction in columns of different tables
I have been trying to perform a select that subtracts a column in a table, by another column in another table. See in the image below what I need: Therefore, I need to add the column quantidade…
-
0
votes2
answers127
viewsConvert HTML5 table + images to CSV or SQL
I’m in big trouble! I have basically 1.5 million records including images in an HTML5 table (it already starts there, the browser does not render all images). My idea was to convert this table to…
-
0
votes0
answers52
viewsSubquery in Informix Bank
I have an appointment that seeks sales of a period: SELECT cxpdvend.filial, cxpdvend.dtpedido, cxpdvend.pedvenda, ciendere.nro_endere, cipessoa.nomepessoa, ciendere.celular, cxpdvend.codagente,…
-
0
votes1
answer47
viewsSubquery returning null value
I am doing this query, and I need to query the cost value of a product using a subquery, because the note table is the same as input and output. The products do not repeat. What differentiates sale…
-
0
votes1
answer647
viewsHow to add SQL Server primary key?
Good morning! maybe it is simple my doubt, but... I would like to know how to add primary key in a table not being at the time of creation (CREATE), I know that when accessing the table in "Object…
-
0
votes1
answer59
viewsError in IF condition
I’m doing a program in PHP but I’m having a problem. I want when $user_info is the same as Tiago Goncalves, to show the user’s image. The truth is that all 3 images are shown on the website. HTML…
-
0
votes2
answers82
viewsSQL Updating Wrong Value
I am creating a QUERY to change every day of the dates registered in the BD to the last day of the month of that record... what happens is that when I play the QUERY selecting a record in the month…
-
0
votes2
answers1286
viewsSort date by month
In the development of a query, I’m having a problem sorting the months. For example, in the chart appear to me first April, then January, June, August... And what I wanted to get, was the order of…
-
0
votes3
answers636
viewsAverage all records in a table and update column in MYSQL
I need to do a Query that passes in all table records and updates the rate_general column (this column is the average of the rate_food + rate_service + rate_price + rate_environment / 4 ) notes of…
-
0
votes0
answers28
viewsConnect my pc database to hosting
I want to connect the hosting in the local database of my PC I am using linux. I have ports 1604 and 8080 open. When I access my ip:port on an external network, I can access my website. But when I…
-
0
votes1
answer82
viewsHow do I turn some rows into columns?
I have this database of questions and answers And I need to create a view that the questions and answers are arranged that way. . A friend of mine said something about an anchor but I can’t get it…
sqlasked 6 years, 3 months ago Lucas Pacheco 3 -
0
votes1
answer47
viewsHow can I not let you register any foreign key?
I have a database of an electronic urn with the following tables: Voter(Pk title ) Votoscomputers(Fk quibbler , vote) To my knowledge, the table VotosComputados should not insert a FK any, and yes…
-
0
votes1
answer50
viewsProblem with SQL (duplicate addition)
I have a bidding system that works with a robot giving automatic bids, and also with a button where the customer can bid. When the client clicks on the button, it calls a function that executes the…
-
0
votes2
answers54
viewsDecreasing the value of two fields of a table and sorting according to the result
I have the field "killed" and "died" in the table, I need to make the order of the results come as the decrease of these two values, Example: My query is like this: $woes = DB::table('woeplayerrank…
-
0
votes1
answer31
viewsHow to make a request and search for a string
I wonder how I give a request and look for a string, example: *www.site.com/index.php? id=' (Error SQL) (find the error) I’m just having trouble with it since it’s almost all set, so follow the…
-
0
votes1
answer67
viewsRelationship in tables in the database
I have a table in the database called Veiculo and it has the following fields: placa, renavam, marca, cor and categoria. To the placa and renavam is all right, since the data are unique. My question…
-
0
votes1
answer35
viewsJoin in sql that returns everything
I have two tables, the episodes and episodes seen, I need to make a query that will join the two by the id of the episode, however I do not want the episodes that are not in the second table do not…