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
answer1030
viewsWhat is an "active Autonomous transaction"?
I’m getting this mistake: ORA-06519: active Autonomous transaction Detected and Rolled back ORA-06512: at "SGR20.CR_PKG", line 289 View program sources of error stack? Before anyone asks the error…
-
1
votes0
answers183
viewsSort table by an attribute that is not in the SQL Query
I have the following query in my PHP code: SELECT id, totaldias, totalferiados FROM dias WHERE MONTH(data) = '$mes' ORDER BY totaldias So far, so good. But I implemented in the system a percentage…
-
1
votes1
answer89
viewsCreating 7 selects with PHP and Mysql
I have a database and I want to retrieve its contents and present it within <select>'s, the initial I get, I have 7 names in the database and I can present them all in the same select box,…
-
1
votes2
answers181
viewsRelation between 3 tables and find the result of last week mysql
I have three tables, the tbl_recursos, tbl_categorias and the tbl_categoria_recurso. To tbl_recursos is the listing of resources posted by the user. A tbl_categorias are the categories a resource…
-
1
votes1
answer3334
viewsUsing Group By in SAS Guide
I’m having trouble using the command GROUP BY, in the SAS. By definition, SAS only accepts the GROUP BY if used in the SELECT a summary function. So far, ok. Running the Proc below, the result comes…
-
1
votes2
answers1371
viewsUse mysql_fetch_assoc more than once
I have a big question about mysql_fetch_assoc in while. what happens is the following, I have a page where I do a database search and return to a while existing information with mysql_fetch_assoc,…
-
1
votes1
answer148
viewsselect like that returns a Sting without line break
I am using the following query: select distinct con_destinatario from tab_conhecimento where con_destinatario like '%CALLE%' order by con_destinatario; and get several results of this type: A.S.…
-
1
votes1
answer845
viewsSelect in SQL Server with Intel
I wonder if it is possible to select in Sql Server a table that does not have an index column, but in this select display a sequential index column in ascending order. Ex. Table: Lettering Coluna D…
-
1
votes1
answer116
viewsSearch 3 results from the same table grouped by the same id
I have the tbl_ocorrencias which records occurrences of a particular vehicle. That is, the table consists of the following: - tbl_ocorrencias - id_ocorrencia id_viatura data hora In this case, an…
-
1
votes1
answer1292
viewsFill a parameter field in Crystal Reports
I have a report from Crystal Reports where I must pass parameters for the search, however one of these parameters must come filled with a default value that is nothing more than a field of type memo…
-
1
votes1
answer295
viewsPurposeful Cartesian product
I need to create a purposeful Cartesian product, for a report on Fast Ports that is to multiply my data by a given number EX: select cli.cdclifor, CLI.nmCliFor from cadclifor cli where cli.cdclifor…
-
1
votes2
answers340
viewsError in converting dates during an Index
I need to load a table into a database with data from another table and another database. It turns out that in the Datetime field is giving a conversion error, because the data of the other table is…
-
1
votes1
answer228
viewsView [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
About VIEW in database... What is the difference between the three algorithms when creating a VIEW with [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]? What each one does?…
-
1
votes1
answer387
viewsIs there any technique for synchronizing a SQL Server database structure?
I had some problems recently when making modifications in the type approval environment and for bureaucratic reasons these modifications could not be inspected in the production environment and were…
-
1
votes1
answer1218
viewsSearching for the next record and the previous record using two columns for sorting different tables
I have the following database structure: ___ Table: modules___ id int(10) name varchar(50) position int(10) ___ Table: lessons ___ id int(10) module_id int(10) FK position int(10) name varchar(50)…
-
1
votes2
answers223
viewsCurrency fields 1.99 saving as 199 on Access
I have a problem when I go to save the data of fields currency or decimal in an Access database using Visual Studio components. When I save something like 1.99m or has 1,99 in the textbox the data…
-
1
votes2
answers10731
viewsGet date with day of week, number of week, month and year
Is there any way to get the date if you only have the day of the week, the number of week, month and year with Mysql? Example: I want to know what day it is with these parameters: Year: 2014 Month:…
-
1
votes2
answers324
viewsGeneric repository with SQL
Seeing this question: Here I wondered if it is possible/right to use a scheme like this in a project in which I do not use any framework for connection to a database. I would like an example of the…
-
1
votes1
answer129
viewsHow to add Midia in Wordpress Library programmatically?
Consider the situation where hundreds of files .jpg are already available in the directory wp-content/uploads/2014/09 by default and we need them to appear in the Media Library…
-
1
votes2
answers2679
viewsFill Dataset with Datatable
In C#, how can I declare and fill a Dataset with a Datatable? My idea is to pass the data resulting from a query in the Database to the Dataset, then fill a Report with this Dataset. It is possible?…
-
1
votes1
answer78
viewsAdd items from table 1 and bring in indexed Rows from table 2
I am very new with SQL and I am creating an application that brings the number of hours contracted, well the part that I have doubts in the query is the index of lines... I need the rows not to…
-
1
votes1
answer464
viewsmaps, php, sql. Enter coordinates into the database and reaver map (google) with these coordinates
I have a dynamic map (at least I would like it to be), I wanted it to depend on the user, he entered the coordinates (based on a form) that he wanted and they were entered in the database... so far…
-
1
votes1
answer4533
viewsHow to bring only the records that have no association in the second table?
Personal I have a query that returns the number of registered phones in each state,parents and also brings the number of customers who have no phone registered in each state,parents but I would like…
-
1
votes3
answers906
viewsCan a primary key be used on a foreign key?
The following example may occur? | Id | nome | data | qnt | PK -> Id FK -> (Id, qnt) Or is there some kind of restriction?
-
1
votes1
answer64
viewsHow to make these SQL requests?
I’m developing a real estate portal but as it’s the first time I do one, I don’t know exactly how the logic works to achieve the desired result. After plotting a path, I’ll still have to turn it…
sqlasked 10 years, 1 month ago Marcos Vinicius 7,188 -
1
votes1
answer84
viewsHow to search for records that fit into any category of a list, even if the category name only partially matches?
I have this instruction: $nova = (explode('/', implode('/', $_GET['tipo']))); Which results in this array: Array ( [0] => CONJUNTO [1] => SALA [2] => LOJA ) When I do this query in my…
-
1
votes0
answers59
viewsHow to search by distance
I have a database with coordinates of several locations. I would like to know how, from an informed location, to get only the places you are until a certain distance. I saw a similar question: How…
-
1
votes1
answer690
viewsSorting in Crystal Report with sub reports
I have in my report 2 subs reports but I want to sort by the field "Student" of the Main Report but I’m not succeeding, even though I already bringing from the query it ordered with I would like. I…
-
1
votes1
answer157
viewsHow to get the records found and not found via IN
I have a simple command SELECT MATRICULA FROM ALUNOS WHERE ID_ALUNO IN (1,2,3,4,5,6) I would like to know how to get via SQL a result like this: ID| STUDENT 1 | LUIZ 2 | MARIA 3 | 4 | JOÃO 5 |…
-
1
votes1
answer702
viewsVBA DELETE command does not work
I have a project that adds and eliminates dates, to add I have the following code: Set dbs = CurrentDb dbs.Execute " INSERT INTO TMP " _ & "(diaMes) VALUES( " _ & "'" & tmp7 & "') "…
-
1
votes2
answers198
viewsSemantical Error - Doctrine createQueryBuilder
But once I get caught using Doctrine. I wanted to do it: SELECT c.nm_computador, c.te_ip_computador, log.usuario, log.data FROM computador c INNER JOIN log_user_logado log ON c.id_computador =…
-
1
votes1
answer114
viewsRestrict a character limit array in the LIKE
I have a question about the LIKE of T-SQL. Is it possible to restrict by a number of equal characters to check how many addresses start equal and can end different? Sort of like this: Where Endereco…
-
1
votes1
answer1607
viewsTrigger for a Select
I would like to know if it is possible to execute a Trigger when a SELECT is performed in a given table, for example: CREATE TABLE IF NOT EXISTS "Conversa" ( "idConversa" SERIAL NOT NULL,…
-
1
votes1
answer250
viewsHow to use Foreign key in SQL statements?
I’m wanting to use Foreign key but I’m not getting it. This instruction SQL will create a table called tbl_estado with 4 columns id, nome, uf, pais and in the column pais will enter the key Foreign…
-
1
votes3
answers211
viewsHow to go through the tuples for an ID and check their values?
In a table where I record the amount of plots and the situation of each of them, I need to go through it and find the sales orders where all plots are paid. Ex: SELECT * FROM tabela_parcelas WHERE…
-
1
votes2
answers421
viewsMore than one table in the query - LEFT JOIN SQL
Help with SQL: Query: SELECT * FROM concursos LEFT JOIN concursos_categorias ON concursos.id = concursos_categorias.idConcurso LEFT JOIN categorias_concursos ON concursos_categorias.idCategoria =…
-
1
votes3
answers3234
viewsMake an UPDATE with the value of another database
My bank is like this: cd_endereco | ds_endereco 1 | Rua joão e maria 2 | Rua Manuel Silva And in the other database, I have the same columns, while cd_cliente. I want to pass the values of this…
-
1
votes1
answer3350
viewsHow to save a file to a field in SQL Server?
I would like to know how to save a file within a SQL Server field com C#. Reading on some forums I realized that there is difference between image and binary files. The type of file I want to save…
-
1
votes4
answers1852
viewsOracle11g - Problems SELECT command
I’m making the following mistake: java.sql.Sqlsyntaxerrorexception: ORA-00933: SQL command not properly ended This happens after I run the following line from SQL: /* Listar todas as reuniões do…
-
1
votes1
answer930
viewsError running a Firebird Trigger
I have the following Trigger generated in my database: SET TERM ^ ; CREATE OR ALTER TRIGGER ATUALIZA_CODNCM FOR EST_ADICIONAIS ACTIVE BEFORE INSERT OR UPDATE POSITION 0 AS begin UPDATE…
-
1
votes2
answers10106
viewsChange SQL SERVER SA Password with Windows Admin Account
I received a machine with an instance of SQL Server 2008 installed, I can access this instance through SQL Server Management Studio Express with my Windows administrator account but I can’t perform…
-
1
votes1
answer1120
viewsChange zip code column by inserting dash in Firebird
I have a table of cities where I own the Zip Code. The data looks like this: 89620000 I’d like to leave it at that: 89620-000 How can I do this in Firebird?
-
1
votes1
answer324
viewsError of consultation per month
I need to let the user choose the month to calculate the ESTDIA. In red and bold line. When I leave the :MES and executes the error and leave already set example V.OUTUBRO the SELECT wheel…
-
1
votes1
answer186
viewsError in SQL 2008 Express installation (Silent Mode)
The installation parameters are as follows, but when trying to do it gives error and the installation is aborted. C:\Setup.exe /QS /ACTION="Install" /FEATURES="SQL" /INSTANCENAME="SQLEXPRESS"…
-
1
votes1
answer205
viewsTransform javax.persistence.Query to Arraylist
It is possible to transform a javax.persistence.Query in ArrayList. I need to return an object of the type Query but it cannot have all the values of the result. I want to eliminate some results…
-
1
votes2
answers543
viewsJava error SQL query
I am trying to make a webapp in java , however I am beginner , in the login part of the app, I created a routine that receives as parameter an object and performs a search in the database according…
-
1
votes2
answers770
viewsHow to calculate average time?
I have a table named visitantes in it I insert the hora_que_entrou and the hora_que_saiu of my user on my website. These are in format DATETIME. I would like to run the average they passed onlines,…
-
1
votes1
answer214
viewsUsing Left Join on Datatable Server-Side
After several attempts, I still haven’t been able to implement a 100% left Join within the Datatable Server-Side Note, the following code works 100% HTML <table id="datatable_fixed_column"…
-
1
votes1
answer72
viewsOR returns unexpected result
I’m performing that function SELECT COUNT(id) FROM `system_stats` WHERE `name` = 1 OR 0 AND `us_id` = 0 It returns me a value equal to 1, but this 1 no, when I run separately this way, it returns me…
-
1
votes1
answer1100
viewsSelect with value lookup in another table
I have a table with foreign key fields, and would like to return in a select the value of the item for the key. For example, I have the following table formed with the query: SELECT cod_produto,…