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
answer32
viewsSQL query with 3 tables, summation in 2 and aggregation
Hello. I’m using the Firebird 2.5 database and I have 3 tables: Customers (client/patient registration); Consultation (consultations that customers have conducted); Payments (informs the amounts…
-
0
votes1
answer109
viewsRestore a Postgis dump 2
I am trying to restore a dump from a postgresql database with postgis template. When I try to restore the dump by terminal, I have a number of errors. Command used terminal: psql archeology -U…
-
0
votes1
answer354
viewsDifferent result between select, after applying SUM() and Grop By
I’m making a call report from elastix and I have a problem here in the outcome. Theoretically, if I don’t touch Where, the result would have to be the same. select distinct (case left( devices.id…
-
0
votes1
answer210
viewsSQL CE Insert Error in Database
I am creating an application for a PDA, when I try to insert data in the database I always find this error. There was an error Parsing the query. [ Token line number = 1,Token line offset =…
-
0
votes2
answers11150
viewsHow to Mount a Transaction with Commit and Rollback on Oracle?
I’m trying to mount a transaction on Oracle, but I don’t know how to perform a Rollback in case there’s an error in one of the querys. I searched some websites, but I couldn’t find anything clear…
-
0
votes1
answer1533
viewsHow do I enter into a ternary relationship?
I am creating this model however I do not know if it is correct. I have basic knowledge in database. How do I enter into a ternary relationship that happens in Supplier - Suppliers_has_product -…
-
0
votes1
answer1055
viewsSave data to the database using Form in Cakephp
I’m trying to make a tool for the administrator, the site I’m building, that will allow you to upload images to a folder on the server, so that they appear posthumously in the gallery. The image…
-
0
votes2
answers2742
viewsHow to Migrate SQL Server Database to Oracle
I created a diagram on sql-server, where it automatically creates the entire database structure, only that I will have to migrate to Oracle. I can migrate the whole structure (tables, Fks, Pks,…
-
0
votes4
answers1022
viewsHow to keep column 'order' in sequence even after editing the order of records?
I have a table with n fields, one of which is the 'order' (obviously it is sequential: 1, 2, 3, n...): id | ordem | nome ------------------------ 1 | 1 | Fabio 3 | 2 | Gilmar 2 | 3 | Rodrigo 9 | 4 |…
-
0
votes2
answers1051
viewsSQL QUERY get Average one month of a relative day of the week
I need a query that returns me to the average of a relative month, and a day of the week. For example: I need to know the components relating to the month of February, the day of the week Monday. It…
-
0
votes1
answer579
viewsHow to transform a query output into xml in Informix?
It is possible to take any output of a query directly from the bank and bring the result already formatted in XML text ? This using IBM Informix v11.50 database and natively in the database. Where…
-
0
votes1
answer124
viewsBatch calling "dtsx" does not connect to Avaya CMS
I created a service in dtsx that needs to connect to CMS Avaya. It turns out that when I run it through Visual Studio it follows the process until the end normally. But when I call one batch it does…
-
0
votes1
answer1157
viewsShould I control the status of a system with a single table or several?
My question is somewhat conceptual and allows several interpretations. I am responsible for a system that uses status in several modules. Cargo status, order status, payment status, etc. For status…
-
0
votes1
answer3314
viewsHow to pass values to Procedure - PL/SQL parameters
I asked the management company of our system to change the code of some neighborhoods of the system, the same carried out such change, now I need to change the code of other neighborhoods that are…
-
0
votes1
answer840
viewsCalling Function or Procedure Multiple Times
How to create a Function or Procedure that calls another Procedure to perform a neighborhood exchange on my ERP system? Below is the precedent I want to define values for its parameters. It should…
-
0
votes1
answer215
viewsOrmlite Inner Join in five tables
I want to create some JOIN in five tables like this example: SELECT * FROM TableA AS TA INNER JOIN TableB AS TB ON TA.Id = TB.IdTA INNER JOIN TableC AS TC ON TB.IdTC = TC.Id INNER JOIN TableD AS TD…
-
0
votes1
answer5107
viewsHow to average a mysql query result?
How do I get the "Count(t2.id_atend) TOTAL_ATENDIMENTO field " and calculate his PHP media? SELECT t3.desc_serv, t3.nm_serv, t1.nm_usu, count(t2.id_atend) TOTAL_ATENDIMENTO FROM usuarios t1 INNER…
-
0
votes2
answers315
viewsInsert error with Adocommand
In Delphi XE4, SQL Server 12, connected by ADOConnect. ADOCommand1.commandText being 'insert into tabela (a,b,c) (1,1,1)' It works as expected if a record already exists. But if it is the first…
-
0
votes1
answer5423
viewsHow to disable a Constraint in ORACLE?
I have a table where two specific fields together cannot have the same values. I BELIEVE who are they: NUM_PERIODO_LANCAMENTO COD_INDICADOR Assuming I have that data: NUM_PERIODO_LANCAMENTO = 1 ,…
-
0
votes1
answer8195
viewsMerge two Select
I am developing a report in Powerbuilder and would like to know how I can join results of two SQL queries in the report. If I add the f_bloqueto_nosso_numero function in the first querie and add the…
-
0
votes0
answers409
viewsTrigger error involving Linked Server
I created a Trigger that fetches data from an SQL Server table and writes or updates data from another table in Oracle if there is a change. All this via Linkedserver. But executing it generates the…
-
0
votes1
answer870
viewsPdo UPDATE does not work
I’m trying to send some values to SQL, but PDO does not work as it should, or I’m forgetting something, I’m new to using PDO. Example of functional code. $conn = new…
-
0
votes1
answer411
viewsI cannot insert plain text in mysql with text column
I’m not getting a simple update on a table that contains a column TEXT. I put a simple Spanish text but sql returns me error saying that line is too big. However it is a very small sentence. Follow…
-
0
votes1
answer3407
viewsImport XML to Oracle tables
. Hello, I need to import an XML file to an oracle table. There are several examples on the internet, but none of them worked for me. In general, I’m having the error: LPX-00210: expected '<'…
-
0
votes1
answer351
viewsChange language in the database during a query
Is it possible to change the language of the database only during the execution of an insertion query? I am having problems with date conversion due to the formation of them, the Bank expects…
-
0
votes1
answer724
viewsMS Access - how to get 30-day date range
I need to collect registered orders from a table with the name Pedidostalao in the last 30 days.
-
0
votes3
answers1701
viewsReturn of SQL SELECT
I need to make a select comparing whether user login already exists or not. But I do not want to return values from the table, only a symbolic value to verify the existence (true or false). The…
-
0
votes1
answer5030
viewsJava check, show values recorded in Mysql database
I need help I’m making a game in java and I need all records and files and player etc in my table but I can not connect with the database and much less check and display values Ps: sun.java tutorial…
-
0
votes1
answer155
viewsQuery that selects last line of each device?
I have 3 tables in my DB: CREATE TABLE IF NOT EXISTS `local` ( `codigo` int(11) NOT NULL AUTO_INCREMENT, `IMEI` varchar(15) NOT NULL, `latitude` decimal(10,6) NOT NULL, `longitude` decimal(10,6) NOT…
-
0
votes1
answer374
viewsError using sql Insert(SQL Server) command, via classic ASP
Good evening, I have a problem running an sql command through an ASP application. This is the command: strSql = " INSERT INTO movimento_tef_nsu ( "&_ " identificador "&_ " ,nsu_sitef "&_…
-
0
votes2
answers788
viewsregistering php data in SQL server database 2008
I have a question... I don’t know if I’m putting the Cód right, I’m a beginner in php and I need a help... I already managed to make the form I have to write in Mysql ... but now I’m working on an…
-
0
votes2
answers722
views -
0
votes1
answer62
viewsUse distinct in Row
Good staff I am with a doubt, I am trying to return from the comic only states that possess the searched term however I do not want to repeat them. follows the code <?php $search_term =…
-
0
votes1
answer439
viewsOffline database
I’m creating a program that uses a database on file. I was told that the Sqlite is for this, I can create database with it and access by file. In that case, would I use the SQL or JDBC library to…
-
0
votes1
answer111
viewsMysql Stored Procedure Error
I have a table of links that I need to delete every month to include new data. I made a stored process to automate this process. This table has about 3 million rows in a monthly period. This can…
-
0
votes2
answers729
viewsHow to fill datagrid in a form with fields in another form C#?
I’m making a loyalty system, and I wanted to use two forms for customers, Form1 with the datagridview and a button register and the other form2 with the data fields to be filled in, that form2 would…
-
0
votes1
answer318
viewsSQL history query
I am in need of a help with SQL. I need to do a query that returns a history of the current date up to 7 days behind. Could someone please help me?
-
0
votes1
answer84
viewsSelect saves same data in 2 different fields
I need that when the employee selects the product the input "product code" be filled automatically, so far so good but when write the data in the BD, the fields product and product code keep the…
-
0
votes1
answer329
viewsWhat are the differences between sql commands?
What’s the difference, when I should use the following sql commands and which expressions can follow these commands? order by ,group by, join e union What is it for and when to use the commands…
-
0
votes2
answers142
viewsWhy this SQL syntax error?
$termos = (explode('/', implode('/', $_GET['tipo']))); print_r($termos); Array ( [0] => CASA [1] => CASA EM CONDOMINIO [2] => COBERTURA ) I have a syntax error in this SQL that makes loops…
-
0
votes1
answer1021
viewsHow can I paginate these results?
I made an SQL to filter results according to the desired parameters which resulted in the following statement: $query = $pdo->query("SELECT * FROM imovel ".trim($where, ' AND ')); Whereas I used…
-
0
votes1
answer101
viewsHow to sum up the days according to a period?
How to sum up days according to a period? Example: +--------------+--------------+--------+----------+ | data_ini | data_fim | codfun | qtd_dias | +--------------+--------------+--------+----------+…
-
0
votes2
answers835
viewsSelect only columns with values
I have a table with a sequence of fields with almost the same name, changing only the final character, and I need to make a query that returns only the columns with some value, currently I do the…
-
0
votes1
answer37
viewsHow to get all lines using duplicate value in IN
How do I get all lines using IN(), and inside IN() have duplicate values SELECT NOME FROM PESSOA WHERE ID IN (1,1,1,2,3,3,4) I want in return come 3 times the name of ID 1, and 2 times the name of…
-
0
votes2
answers248
viewsTo do a complex search I would have to use OR to combine all the instructions?
I would like a help to make SQL as per the data in this figure. What I know is that if I send AND for all characteristics and one of them return false or erro all SQL will be compromised. I thought…
-
0
votes1
answer121
viewsRewrite the code to display expected result?
This code must return all records from the table immovable if the array is empty and returns selected records if there are items in the array. I can have the array mounted and the database consulted…
-
0
votes2
answers234
viewsHow to make this SQL request with this particularity?
In this search when the array returns the 4 as the SQL demonstrated below, I need the system to return all the results whose number of dorms and >= 4. You can help me get this result. I converted…
-
0
votes2
answers1263
viewsRun SQL files inside subdirectories on Linux
I have an SQL file repository where each one represents a stored Procedure. These files are inside a directory organized in other subdirectories. Example of my directory structure: stored-procedures…
-
0
votes2
answers781
viewsHow to perform more than one select for only two fields from another table
I’m not able to select more than one table to display only the ID and name data (table t_cadclients), I’m performing the SELECT of the entire t_cadcontracts table with WHERE in the contract number…
-
0
votes1
answer108
viewsRails 4 select Uniq
I have the table Items: id enrollment_id turma_id 11 2 2 12 2 3 13 2 2 14 2 2 15 2 3 I want my result to be this: id enrollment_id turma_id 11 2 2 12 2 3 That is I want all the items, but that does…