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
votes0
answers94
viewsHow to take the value of an id that is incremental and use it as a foreign key without using set/get?
I have a Primary key and needed to use it in another table like FK, how do I insert into the bank in a way that does not need to use the set or get modifiers?
-
1
votes2
answers167
viewsCombobox come blank VB.NET with INNER JOIN
I’m having a little problem here and I haven’t found the solution yet, I’m loading data into a combobox using a DATASET from a INNER JOIN done in a database SQL SERVER. Until then it’s okay only…
-
1
votes1
answer891
viewsMake a select in a varchar column as if it were SQL datetime
The code is as follows:: SELECT data FROM lista WHERE data BETWEEN '01-08-2015' AND '05-08-2015'; The problem is that the date column is a varchar and I would like to use it as a date…
-
1
votes0
answers98
viewsSQL Server - Doubt and relationship between tables
I have a precedent in my BD in which it makes register material in the database, so far so good, but in the registration process I need to update another table assigning the amount of material to a…
sqlasked 9 years, 6 months ago Gilvane Silva 81 -
1
votes0
answers95
viewsSee which user created or changed a Linked server
Sirs, How to audit the creation or modification of Linked Servers in SQL Server 2008 or higher? (See who created or changed a Linked server).
-
1
votes1
answer47
viewsProblems with Regular Expression
I have the following beginning of Function sql I will use for a recreation system procedures/Function in C# Create Function dbo.JN_FN_DataAtual(@TESTE INT) And created the regular expression…
-
1
votes2
answers159
viewsfetch_array does not return data
I am making a user list and the data does not appear on the page. I waited for the user’s name, his type and the number of posts and responses he sent to the system to appear. There is another…
-
1
votes2
answers2579
viewsGet last record of each id in sql query on condition
I’m having trouble getting the last record of each id in an SQL Server table. select c.Serial,v.Descricao,v.Placa,v.Cor,v.AnoFabricacao,v.Chassi c.DataHora,c.Endereco from [CheckPoint] c inner join…
-
1
votes1
answer663
viewsLEFT JOIN with WHERE in the field of the first table OR field of the second table
SELECT COALESCE(tb2.numero_novo, tb1.numero_original) as numero FROM tb1 LEFT JOIN tb2 ON tb2.id = tb1.id WHERE tb1.numero_original = <PARAM> OR tb2.numero_novo = <PARAM> The above query…
-
1
votes1
answer212
viewsSelect dynamic query button Submit and input
How to make a dynamic select in JSTL by a JSP? For example, fill CNPJ in a input id="cnpj" and when I click on the Submit button it takes that value from input, plays in SQL QUERY as parameter and…
-
1
votes1
answer27
viewsProblems entering a datatime record
This is the description of my table in Mysql That’s how I’m inserting the records insert into pedido (data_criacao,data_entrega, entrega_cep,…
-
1
votes0
answers61
viewsPassing sql in CAKEPHP array input
I need to make 3 queries, if x icon is enabled, make query X. If it is y icon, query y. If both are, I want everything from x and y query. I can get the x and y query, but when it comes to getting…
-
1
votes1
answer207
viewsGet the parent by passing the child code using Hierarchical Data (SQL Server)
How do I get EmployeeID of the father passing the EmployeeID of the child in the table below using the type variable hierarchyid in SQL Server? CREATE TABLE Employee ( Node hierarchyid PRIMARY KEY…
-
1
votes1
answer81
viewsError Mysql syntax
Good morning, I have an error in my upload system. The error is the following: You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right…
-
1
votes0
answers73
viewsVertabelo - Warning: Reference Name seems to be invalid
I’m using the vertabelo because I need to share my program with others, but when I brought my work to it. He appears the following warnings, someone knows what it is? link:…
-
1
votes1
answer458
viewsInner Join table on 1 = 1 can be considered a gambiarra?
I have a table of provas and a table of alunos who have no direct relationship, I still have a table of inscrição aluno and a table of escolas, as follows in the modeling below: I need to create a…
-
1
votes1
answer5793
viewsHow to close all active connections?
I have 8 open connections in the database and would like to close all of them, is possible? What is the Mysql command that does this?
-
1
votes1
answer1121
viewsShow only one record of each ID
I have a table Clientes and a ClientesTel. I need to present a list where the Código do Cliente, Nome, Telefone e o email, but by the structure I can have several phones. Follow the SQL I’m trying…
-
1
votes1
answer67
viewsProblem with product update
In the query the goal is to update the unit of the product, with a subquery which retrieves the current unit from the bank and subtracts by checking by code. UPDATE loja.produto SET UNIDADE =…
-
1
votes2
answers236
viewsError bringing Time and Date
I am registering in the Mysql database values such as time and date. Code JAVA: public String getDataPedido() { StringBuilder horaSistema = new StringBuilder(); GregorianCalendar pegarHora = new…
-
1
votes1
answer64
viewsAutomated Deploy - Multi-customer version maintenance
How best to automate deploy ? Having 1 deploy for each client, what is the easiest way to maintain all these deploys ? Database Migrations and all version processing? In an example you have 100…
-
1
votes2
answers104
viewsData string-to-date Procedure
I am creating a Trial, which receives a date string '2015-09-11', checks if it is indeed a Monday, if not, it takes this date and play for Monday of the week itself. But my concept with sql is very…
-
1
votes1
answer80
viewsList as equal 3 column-Count
Well I think this is in css what is not my thing, I would like to be listing the results of the comic and pass the next result to the next column tried to use ( abridged) SELECT * FROM anuncios…
-
1
votes2
answers6796
viewsMysql error 1215: Cannot add foreign key constraint
How do I fix this mistake? I know one of the reasons for this is that the columns need to have the same size and specification. But I’ve tried everything and it’s not working. CREATE…
-
1
votes1
answer147
viewsUpdate tables with the same data in the row
When I add a category A, and add a product X with the category A (table categories), then edit the category name A for category B, the category of product X (products table) remains with the…
-
1
votes1
answer217
viewsAES128/256 C#. net AND SQL 2008/2012 encryption
Greetings, Does anyone know of any AES compliant encryption implementation between c# and SQL? I want to encrypt in C# and decrypt in SQL.
-
1
votes3
answers565
viewsRepeat LEFT JOIN with other parameters in the same query
I have 2 tables: FATHER: id nome SON: id idpai sexo_filho I wanted to make a SELECT that adds up the amount of children male and female, that’s the problem, I can only do with one of the sex: SELECT…
-
1
votes1
answer41
viewsSQL - Select all records with encoding errors
Make a select in the database bringing all records with coding errors: SELECT * FROM tabela WHERE titulo LIKE '%ÇÃ%' Does anyone know another more efficient way?…
-
1
votes2
answers24
viewsComparing Salary among Arrays()
I have the following Query: SELECT * FROM folhapagamento_storages WHERE idFolhaParametro = '1' AND valor_min >= '1083.4' AND valor_max <= '1083.4' Only that the return will always be 0, what…
sqlasked 9 years, 1 month ago Sr. André Baill 6,946 -
1
votes1
answer28
viewsReturn tags associated with posts
I use the query below to return all posts marked with the tag set: SELECT imprensa_posts.slug AS slug, tipo, titulo, data FROM imprensa_posts JOIN imprensa_tags_posts ON imprensa_tags_posts.id_post…
-
1
votes1
answer92
viewsOptimization of SQL Query
I set up a series of SQL but I’m having difficulty generating something that stress less the server, I ask help from you. Follows the SQL: SELECT '2015-06-10 00:00:00' AS 'Hora', COUNT(id_contato)…
-
1
votes1
answer91
viewsHow to Perform a Procedure at Every Insert?
When I go to register I want according to the selected category to record a moderator id, in the question table. select idcategoria from tb_pergunta select idmoderador,idcategoria from tb_moderador…
-
1
votes2
answers198
viewsHow to mount PDO query with items previously concatenated
The doubt is the following, in mysql we can concatenate a query and then perform the search, as follows: $cidades = '&& (cidade = 100 || cidade = 101 || cidade = 102)'; $order = 'id ASC';…
-
1
votes1
answer130
viewsHow to return NULL in LEFT JOIN?
I have two tables I need to manipulate: interventioniscy : idintervencaopriority , idcelula... cellula : idcelula, name... SELECT ip.idintervencaoprioridade, zc.nome nome_celula FROM…
-
1
votes4
answers489
viewsSub-search with SQL
I’m trying to solve a khanacademy exercise in the SQL course and I’m having a little trouble. The exercise calls for the following: To finish creating the "Pop" playlist, add another search that…
-
1
votes5
answers580
viewsDoubt in SQL query "between" or "in"
I am generating a report between date, as the figure below: However, when I enter the starting date: Initial year: 2014 Initial month: 6 and Final year: 2015 Final month: 5 does not bring the data,…
-
1
votes0
answers204
viewsHow to delete duplicate records in a Sqlserver table
I have a table where I need to apply a new watering, column A + B cannot have the same value. I intend to add a rule like that: ALTER TABLE minhatabela ADD CONSTRAINT minhaconstraintnome UNIQUE…
-
1
votes0
answers218
viewsAccess Database File, SYBASE
I need to remove the data from a database file (.db) that I was told is SYBASE, the client needs to migrate data and I need to access, does anyone have any idea where to start? because never heard…
-
1
votes1
answer583
viewsListview of Android database - Close application with error
I’m implementing a registration with Sqlite3 on Android and so far okay, the problem is in the call of Activity data listing when the registration is successfully performed, when making the call to…
-
1
votes2
answers713
viewsProblem with UPDATE mysql
I have a problem executing an UPDATE command in my Database... My table has 2 columns: -Column 1: link (PK) varchar -Column 2: varchar status I need to update only the "statuz" field of my table.…
-
1
votes2
answers399
viewsSort field or expired date notifications, database
I know nothing about database, I’m using one in Visual Studio (the standard SQL called "Service-based database"), I’ve integrated it into the form and made up the query fields. But there is a field…
-
1
votes1
answer148
viewsUse "SUM" in access + Vb.net
I have a small problem in the Access query , where I have the following code : Dim cn As New OleDb.OleDbConnection Dim cmd As New OleDb.OleDbCommand Dim Da As New OleDb.OleDbDataAdapter Dim Dt As…
-
1
votes2
answers114
viewsReceive variable value in 'Where in'
In my procedure I have the following variables: @Codigo VARCHAR(MAX),@cont as int, @DataPago as VARCHAR(10) Via C# application I am passing the values as follows: y1.Parameters.Add("@Codigo",…
-
1
votes1
answer34
viewsSearch Interlaced ID (mutual), sql mysql
I have a table with this format RELATIONS ----------------- ID | ID_1 | ID_2 all in INT and the ID is self incrementable. She’s filled this way: ID | ID_1 | ID_2 ----------------- 1 | 1 | 5…
-
1
votes1
answer40
viewsProblem to sum values in JDBC
The console presents me the following error: FUNCTION worksoviagemd.SUM does not exist. Check the 'Function Name Parsing and Resolution' Section in the Reference Manual Can only be sql in my…
-
1
votes0
answers192
viewsCreate SQL Tax Table
I am developing a system for budgets and, to finalize my project, I need to create a tax table. To help, follow an example of what I want to do: in the raw material table, each material has a…
-
1
votes3
answers300
viewsRelationship of tables
Good Night, I have a database with several tables and need to make a query relationship 4 tables CREATE TABLE IF NOT EXISTS `cad_cliente` ( `id_cliente` smallint(5) unsigned NOT NULL, `nome_cliente`…
-
1
votes1
answer77
viewsPHP MS Sql query script for My Sql
Good afternoon. How can I make a query in MS Sql and insert the values in a My Sql table through PHP? Looking at this data, you can do this insertion? #--> conexao mysql…
-
1
votes1
answer1949
viewsRelationship intermediate table n for n
I have two tables with relation N to N in my database, with this, I must create an intermediate table that has the PK of each of these two tables. My doubt is: how to insert data referencing the Pks…
-
1
votes1
answer552
viewsRelationship between various tables in Eloquent
I am trying to create the models in Lumen based on my current database for a virtual store, but I am having difficulties to configure the relationships between them. So far I have the following…