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
votes0
answers673
viewsChange data type varchar to int
Is there a problem changing the data type from varchar to int in mysql? I have a spreadsheet with some items that were inserted as varchar, all are numbers. The problem is that I need to do a search…
-
0
votes2
answers484
viewsIncorrect syntax error next to engine
I would like you to help me. The following error is appearing: MESSAGE 102, LEVEL 15, STATUS 1, LINE 17-INCORRECT SYNTAX NEXT TO ENGINE but I couldn’t find him. CREATE TABLE SITE ( SITE_ID INT…
-
0
votes1
answer198
viewsfill in combobox with data from other combobox
I have a table City where has the fields City, Status, Idpais, besides the tables State and Country. I’m making an application in c# where I use 3 combobox. When selecting the first combobox…
-
0
votes1
answer4059
viewsError connecting database (Fatal error: Uncaught Error: Call to Undefined Function mysql_connect() in )
am having problems connecting the database of my website. The following error happens: Fatal error: Uncaught Error: Call to undefined function mysql_connect() in…
-
0
votes1
answer737
viewsReturn rows with the highest value in a column
I have a problem with a query in an Oracle database in a table with 3 columns: ID_Loja | Canal | Valor_Venda There is the possibility of having more than one sale per store and I want to know which…
-
0
votes0
answers29
viewsHow to give a select to only get some mysql record
In the table turma_materia has the following information. CODIGO | MATERIA | TURMA --------------------------------- 1 | 1 | 2 In the table Materia has the following information CODIGO | NOME DA…
-
0
votes2
answers2257
viewsORA-00907: Missing right parenthesis error
I have a select within my query used for summation and every time I add the GRID field of the PA_XCPNT_EVTHST.GRADE table, I get the ORA-00907 error. If I remove the select grid, it works perfectly.…
-
0
votes1
answer72
viewsSearch for values with priorities
I’m looking for a search and I’m not finding the right logic to filter the results I want. I have a table with all the expiration registrations of certain equipment. My problem is related here: The…
-
0
votes1
answer42
viewsHow to change the contribution code for duplicate records
I have a query that returns me 04 duplicated lines; I need to change the contribution codes so that no Pk error occurs. nm_Matricula Mes_Ano_Referencia Mes_Ano_Competencia Cod_Contribuicao…
sqlasked 7 years, 6 months ago Cidineia Okamoto 11 -
0
votes2
answers168
viewsGrouping invoices in php mysql delay
Hello, I’m beginner, I’m learning to select, and would like to receive help from this wonderful community. I need to take only the invoices that are with the a_winning status of each student, would…
-
0
votes1
answer147
viewsBring the word HISTORICAL when the line date is less than the previous dates,
I have a query where I should register the lines with error with the word Historical, the lines that bring the date LESS than any of the dates of the previous lines should present the word…
-
0
votes1
answer322
viewsConversion to date Postgresql
Hello, I am working with a database that has date information stored in a varchar(50) as in the following example: "2012 December 2 18:37". I need to do research based on time intervals. However, I…
-
0
votes2
answers103
viewsPHP-code conflict - blank page
The following code allows the user to log in and direct to a particular page, or log in as an administrator and direct to another page. The user login is working, however when logging out appears…
-
0
votes1
answer6140
viewsCreate new table from another in sql server
I’m doing this query: CREATE TABLE nova_tabela AS SELECT * FROM tabela_copiada; I’m getting the following error: Incorrect syntax near the keyword 'SELECT' Already researched the syntax seems to me…
-
0
votes3
answers2936
viewsCheck last record of an sql table
Good guys, next ... I’m trying to get the last record of a table with an id SELECT * FROM tabela WHERE id = ? ORDER BY id DESC LIMIT 1 Except he’s not returning the last record, he’s going through…
-
0
votes1
answer169
viewsAverage value of entries up to 100km sql
I’m making a query that brings the average values, as long as the distance is up to 90km: SELECT avg(valor),(6371 * acos( cos( radians(-23.2632227) ) * cos( radians( lat ) ) * cos( radians( lng ) -…
-
0
votes2
answers87
viewsQuery INNER JOIN apply bind parameter
Original query: SELECT quantity.order_id, quantity.ISBN, quantity.quantity,orders.customer_id, orders.created, orders.status FROM orders INNER JOIN quantity ON orders.order_id=quantity.order_id"…
-
0
votes1
answer878
viewsDelete in sql - Inner Join
As is the syntax of a query using Inner Join delete in sql, to compare two table code and exclude being equal? Table itemVenda. in table itemvenda a sale was registered whose code is 4. To execute…
-
0
votes1
answer28
viewsPHP & SQL-Query is not being read
I have the following code, something is happening but I can’t understand why. I mean the query is not being read, echo appears immediately saying "error" <?php $_SESSION['message'] ='';…
-
0
votes1
answer179
viewsSQL server field xml filter for a field with namespace
i tried via seq to filter a record that had an xml field, with this xml below: <ns1:Prod xmlns:ns1="uri"> <ns1:ProductID>316</ns1:ProductID> <ns1:Name>Blade</ns1:Name>…
-
0
votes1
answer341
viewsCatch table name with Trigger/Function in Postgres
I am implementing a simple replication form of two tables or more. I have the table replication which has the table name to be replicated and id. To feed the table replication I have a Rigger in…
-
0
votes2
answers710
viewsOperator in postgres function returns SQL Error [42883]: ERROR: operator does not exist: integer = integer[]
I have the following error in a function postgres SQL Error [42883]: ERROR: operator does not exist: integer = integer[] I tried to convert the data to varchar and text but still I could not return…
-
0
votes2
answers481
viewsDoubt - SQL update from PHP form
I have a table where columns 1 to 5 are fixed data that I feed SQL and it appears the listing on the WEB page. On this WEB page I have a form in which the user must answer 3 questions, in inputs in…
-
0
votes2
answers267
viewsStore Procedure not working properly
Galera created a Storeprocedure called, Cancelarnota, that through the use of cursors, back the products to the stock, pass the status of the item to canceled. This working, however, is not setting…
-
0
votes0
answers74
viewsHow to relate these tables, returning specific values?
[Firebird] sgbd - Ibexpert I need to know how to relate these two tables (comment below), so that I get the following results: TABLE:CONTARECEBER DTDOCUMENTO (date entered the system) MATURITY (date…
-
0
votes1
answer57
viewsFunction max E Cast Joins Sql Server 2008 R2
I need to convert an Nvarchar field to Float in a survey, and take the highest value. this function works SELECT MAX(valor) from [Enops].[dbo].[Tbl_Pulsomedia15_Vazao_Eta_B_Bentes] Where valor…
-
0
votes1
answer569
viewsHow to create a JOB in ORACLE for backup?
Good afternoon, you guys! I am still novice in the subject when it comes to sql, I would like to know how to create a JOB (or other operation that does the same) that performs a data extraction from…
-
0
votes2
answers40
viewsReturning the total with the date in a query with the SUM
I need to return a sum of the value field of the table m and together with it the date of the initial field of the field sale_date, and showing Aggregate Function error: SELECT sum(m.value),…
-
0
votes4
answers152
viewsUsing Mysql how to create a Select that searches "together" words
In Mysql how to create a select that searches "together" words. For example: SELECT pessoa FROM tabela WHERE pessoa like '%josedasilva%' But in this way nothing returns. Because it is registered as…
-
0
votes1
answer275
viewsHow to compare two fields of identical values to different sizes?
I have a database in which have fields with the same name but with different size I need to pick the field with the larger VARCHAR. How can I do that ?…
-
0
votes0
answers250
viewsauto_increment command for Id does not work after erasing data and rewriting it
When I create a table with the column "Id int not null auto_increment" and enter values in the table, after deleting the values and reinserting them, the Id does not part of 1, and sometimes with a…
-
0
votes2
answers273
viewsCondition in the trial
Good afternoon. I have a filter, I have several filters. one of these filters is @ST_TIPO -When I get by Parametro BSP I want to filter just by PT.ST_TIPO = 'BSP' -When I get by Parametro 'DIS' I…
-
0
votes1
answer699
viewsSum hours worked Mysql
I have records of a truck’s route on a chart. =================================================== This example up there I have 5 records I picked up in the table checking Speed > 0 The records…
-
0
votes1
answer26
viewsimporting backup by Mariadb terminal
Yesterday I was doing a test in Postgresql of insertion and backup import and export and Postgresql has an SQL import command as follows: psql# \i backup.sql Has something to do with that in…
-
0
votes0
answers38
viewsScript to disregard sql server null fields
Hello, I have a table q has numerous columns (+ 80), I need a script to disregard the null fields and bring only those that have content. I don’t want to use is not null, because it would list each…
-
0
votes1
answer64
viewsformatting sql command export with sed
I have exported a table from my database as follows: "1";"Boi Preto";"2000-02-29";"2";"Sol Nascente";"2009-10-01";"3";"Parque Belo";"2007-03-15";"4";"Pedras…
-
0
votes2
answers1581
viewsFunction with Insert according to a select that returns a list of ID’s - Postgresql
I need to make a Rigger after insert calling a function that takes the last record inserted into a certain table and inserts the ID of that last record into another table according to a select that…
-
0
votes1
answer101
viewsProblem with wp_termmeta table
The following error is permanently occurring, recorded in my error_log: Error in Wordpress Table database 'odiletan_bd.wpTP737termmeta' doesn't exist na query SELECT term_id, meta_key, meta_value…
-
0
votes0
answers17
viewsHelp with combo boxes Database in php in two Forms!
Is there any way to use two combo boxes to vary from each other type this example(Two combo boxes Where one Varies form the other using 2 Forms cant use ajax); This is my database(My database)…
-
0
votes1
answer268
viewsHow to display two tables in Sqldeveloper at the same time?
I am unable to filter two tables at the same time in SQL Developer at the same time. When I insert two tables into the same filter sqldeveloper shows nothing!…
-
0
votes2
answers182
viewsWrite data to a based table and two other tables
Hello! I am new in sql Transact and would like and have the following situation. I have a table that contains the list of columns in a second table. That’s right! In table B the names of the columns…
sqlasked 6 years, 10 months ago Sergio Paiva 15 -
0
votes1
answer479
viewsSearch data between a period in a table with start date and end date fields
I’m having a problem searching for data in a table with start date and end date fields between a period (a - up filter) The sample data are: ID - INICIO - FIM 1 - 01/01/2017 - 31/12/2017 2 -…
-
0
votes2
answers517
viewsLISTAGG function returning repeated values
I have a multi-valued field where I need the result to return in one line, trying to use LISTAGG, but it returns one value per line and each value repeated 5 x. Any idea ? I’ll paste the code so…
-
0
votes1
answer28
viewsCheck codes that are not in the database with a query
I know I can check codes that are in one table and are not in another with the following query: SELECT cod FROM tabela1 WHERE cod NOT IN (SELECT cod FROM tabela2) But how can I check the records…
-
0
votes1
answer113
viewsSPLIT_STRING in several 'paragraphs'
I’m trying to take this kind of table: In which I have a daily import for a dbo, I now have difficulty split_string the comments, cross with the ID. The idea is to have as many lines as (additional…
-
0
votes1
answer227
viewsSelect records between two dates with pre-established minute intervals
I have a table that stores data collected at five-minute intervals. I would like to select the records between an initial date/time and the final date/time. So far I can do it. Only that I would…
sqlasked 6 years, 9 months ago Sergio Paiva 15 -
0
votes1
answer37
viewsCLR . NET - ERROR -> 9521 exceeds the maximum accepted message size of 4,000
My code makes a webapi post from a trigger in an SP that monitors my database. This POST works well for msgs of up to 4000 characters but above that the SP gives this error: "ERROR -> 9521…
-
0
votes3
answers860
viewsmake a select by grouping by year
I have a client field on it I need to make a Count of how many customers were registered during the years 2016, 2017 and 2018 i was making 3 select, being that in each one I was making a Where…
-
0
votes1
answer878
viewsDelete SQL record with dependency
Good afternoon. I wonder how to delete records from a table containing foreign key. I would not like to delete the children records (to keep the history). I always get a message warning that there…
-
0
votes0
answers749
viewsHow to find out in SQL which is the primary key of the table?
I am learning SQL, and ran into the following problem: I need to know which of the columns is the primary key of the table. Have some command I can use in SELECT to get as return that information?…