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
votes2
answers1299
viewsCodeigniter with Modal Screen and Registration Response
I am making a registration of call requests through a modal but I can not handle the registration answer: "Register with Success" Controlling class <?php defined('BASEPATH') OR exit('No direct…
-
1
votes1
answer56
viewsCatch Total value except date
I’m trying to develop a query that will return me a total order value for a particular customer, with an informed date range. For example, between 05/11/2015 to 05/12/2015. The problem is that I…
-
1
votes2
answers161
viewsHow can I use something like an IF in an SQL query
I am applying a query SQL in the Oracle SQL Developer in multiple tables where a Column a view is null in some places and then I will need to use values from another Column and I don’t know how to…
-
1
votes1
answer61
viewsHow do you convert this Sql to Entity framework?
I’m having difficulty passing this sql to the Entity Framework I’m using mvc 4. select pc.Nome, pc.Endereco, pc.Bairro, pc.Numero, pc.Telefone, pc.Email, ma.descricao from PontoDeColeta pc Inner…
-
1
votes1
answer6395
viewsGroup by with SQL Server error
Good morning, I would like to know why my SQL query is not working, I am using SQL Server 2008 and my GROUP BY is going wrong. I have checked and the table names are correct and are filled in…
-
1
votes1
answer664
viewsQuery to return recurrence values, which have not yet been created in the database
I need to make a query in the database where the records are not yet saved. I will explain better: In a system that I am developing, the user can register a recurring expense, that is, it will be…
-
1
votes1
answer61
viewsDoubt to use combobox
Good Morning, I have a final chair work for web development, where I need to create a crud for teams, players, create a style table of the Brazilian championship and create the rounds. I’ve managed…
-
1
votes1
answer656
viewsRedo autoincrement on Sqlite
I am passing the data from an old bank to a new bank. After running all the querys there were some primary key fields that were "missing". Example by column id jumped from data '11' to data '13'…
-
1
votes2
answers371
viewsDifficulty Mounting SQL Query with UNION with SUM
I have 2 tables that stores type of different sales, and I need to add everything to get the amount to generate the charge, however I am not able to mount the sql query, follows: SELECT…
-
1
votes2
answers1896
viewsHow to make a record count for each day between a date and another?
I need to make a query, to return the number of records registered in EVERY DAY, between two dates. I’m using a mysql database, and I tried here, but no way seemed right.
-
1
votes2
answers80
viewsreturn the query as the zend string
I have the following code where I need to store inside the $erro_items variable the complete query with the parameters to analyze what is happening, my doubt is, how do I show this query? $sql = new…
-
1
votes3
answers404
viewsHow to store static information without using a database?
How to store static information without using the database? For example, let’s say that I have a text on a page, which does not need changes frequently, and to avoid using server resources and/or…
-
1
votes1
answer78
viewsTbquery back N records
No Lphi if I give one TbQuery.prior It returns a record. But if I want to go back N records, for example, I want to go back 5 records. Does anyone know if there are any methods in Delphi that do…
-
1
votes1
answer1551
viewsHow to perform statistical fashion in SQL?
I work for a telephone charging system company, all calls generated by the central (PABX) are charged by the system and stored in a call table cadcha. cadcha…
-
1
votes1
answer438
viewsHow to create a select in Firebird?
Create a select listing 03 fields from any table by sorting the data through the 2nd field. I’m pretty weak in Irebird someone can tell me how to do it?
-
1
votes2
answers525
viewsTurn Sequence of Numbers into Data with PHP and SQL
I have a database that has a numerical sequence recorded in a table that means a publication date of an article. I wonder if someone can decipher this numerical sequence so I can print the correct…
-
1
votes1
answer224
viewsParameters in the Query
When mounting a Query using Addwithvalue. Even if right, the return is not as expected. In the example below the return is Zero var query = "SELECT nome,usuario,email,administrador FROM GSCUsuarios…
-
1
votes2
answers71
viewsProblems in an SQL query
Hello, in the following query, an error is shown in the: select fto.id_taxon, fto.cd_sexo as fto_cd_sexo, fto.cd_idade as fto_idade, x.ftv_cd_sexo, x.ftv_cd_idade, x.id_fv from tb_foto_ocorrencia…
-
1
votes2
answers309
viewsSQL update query syntax error
When I run the following update query there is a syntax error before or inside from: UPDATE Artigos SET totale = entradas.sent FROM Artigos INNER JOIN (SELECT cod_artigo, Sum([quantidade_ent]) AS…
-
1
votes3
answers328
viewsHow to compare encrypted data with crypt
Hello, I’m trying to learn how to encrypt data. I created a code php to save the data in the database mySQL and another to compare user input data with the database. To encrypt I used the function…
-
1
votes1
answer164
viewsList posts of friends
I have a database with the following structure: Table users: usuario_id Primária int(11) nome varchar(128) nascimento date Table friendships: id_amizade Primária int(11) id_remenente int(11)…
-
1
votes2
answers1012
viewsFunction with return using 'case when'
I have a Function that returns the status of a request (in the database is as int) that only has two possible values, 0 (inactive), 1 (active). I was trying to increment it with 'case when' in case…
-
1
votes1
answer199
viewsUpdate table with data from another table decreasing character
Hello, I have the bank BDMCOM1 that has a table Product Balance and a column Quantity with values like: 1,000. But I have another bank BDMCOM1_V3_ALEA that also has the table Product Balance and…
-
1
votes2
answers702
viewsDecimal value conversion error in Insert C#
I have an Insert that receives some parameters, more at the moment that mount the sql statement this giving conversion error: Error Converting data type varchar to Numeric.…
-
1
votes2
answers186
viewsHow do I display total records in a Manytomany relationship when I use HAVING?
I have the tables below: Articles tags article_tag (pivot table with the columns article_id and tag_id) In the query below I can recover the articles that have the two tags (with id 1 and 3). In the…
-
1
votes1
answer553
views -
1
votes1
answer53
viewsDoubt with Date Formatting in sql server 2008
In my application I am recording the dates in this format: DateTime.Now.ToString("yyyy/MM/dd"); In the database I have: 2016-01-09 00:00:00.000 Now I need to make a query where I will bring only the…
-
1
votes3
answers1439
viewsWhile inside another While (PHP - SQL)
I searched the forum and the internet, but I could not solve the problem yet! I am making a query in the database by PHP and searching users. After I look for the users I look for his academic…
-
1
votes1
answer99
viewsMysqli Prepare with Loop for Select
I’m trying to make a SELECT using MySQLi and PREPARE in a FOR but not working. Always returning a single zero. Application Code: if( $teste = $mysqli->prepare("SELECT COUNT(*) AS TOTAL_CONTATOS,…
-
1
votes2
answers1051
viewsJob created on SSIS does not work on SQL SERVER AGENT
I have a job created in SSIS (working perfectly) that does not work in SQL SERVER AGENT. The job extracts some data from an access table, via ODBC, and loads it into a sql server location table. Sql…
-
1
votes1
answer108
viewsHow to return an SQL with result?
I need to select several tables linked by the "user id" and return the data to compose a profile page, but some of these tables may be empty at first, that is, the query will not find the "user id"…
-
1
votes1
answer42
viewsDoubts about the use of class
Good morning, you guys. How are you? I am writing a windowsform application, and in some situations I need to make several queries, Insert and delete.. well, so I created a query class, a delete…
-
1
votes3
answers4847
viewsINSERT inside a SELECT - SQL Server
I need to do an INSERT inside a SELECT in some cases in my Query. An example of how accurate: SELECT IdTabela, Nome, CASE WHEN IdTabela > 10 THEN INSERT INTO TabelaExemplo (IdTabelaExemplo)…
-
1
votes1
answer393
viewsSave a field log only if it is Insert (Trigger SQL Server)
I have a Rigger that fires when it is Insert/update FOR UPDATE, INSERT I check if the field was changed with: if update (nome) --faça algo How do I know if I am entering a record in the table to…
-
1
votes3
answers83
viewsDate Doubt in SQL
I’m setting up a database for a video store to learn SQL. My goal is to have a return date of the film. For this, I created the table with a column named "return" to store when the movie will return…
-
1
votes1
answer180
viewsHow to complement these queries to get the buyer’s data in the bank?
I made these queries below to get the data from the buyer’s database and the products he bought. With the first query, I got the ID and with these IDS I made a new foreach that took the products…
-
1
votes2
answers54
viewsDisplay user messages
I have two tables, one of utilizadores where I keep the usernameand the id, and I have another chat where I keep the fields sender and the reciever, which are the user id of the user who received…
-
1
votes2
answers10224
viewsUpdating multiple records to the same ID
Consider the following scenario for controlling license information in a database Products 1 - Solução x 2 - Solução y 3 - Solução z Suppose the Customer has the 3 solutions Licence table | ID |…
-
1
votes1
answer84
viewsProblems to enable remote access SQL Server + Android
Good afternoon I made a webservice on Asp.net, and I need to access it through an android application. In any normal function, it works normally, but if it is a function that has access to the…
-
1
votes2
answers3374
viewsModify foreign key for auto-increment
I have two tables in my bank membro, membro_grupo, grupo The table grupo has a column called id_grupo which is the primary key in this table. The table membro has a column called id_membro which is…
-
1
votes1
answer468
viewsSelect Comparing Periods
I need to make one select comparing two periods of sales, totalling by product. Today I have this select that does this, but only for a period (01/09/2014 to 30/09/2014) SELECT ACC.PRODUTODESC…
-
1
votes2
answers1403
viewsCompare data sql
I need to compare date in a certain time interval. I need to pick up the field DAT_REPOT_REALZ and check the dates between TODAY and seven days ago. I also need to count the number of V (visitor)…
-
1
votes1
answer44
viewsHow to Return Results with Integers and Nulls?
I’m trying to build a Query but they’re not succeeding, in my database I have 28 information with code 32, and 62 information with code 23, but there is information with null code, and I wanted to…
-
1
votes1
answer341
viewsINNER JOIN 3 tables with pivot table
Part of my database consists of these three tables. And I’m trying to come up with an SQL query that tells me the clients by sellers (sellers), i.e., for example: João (sellers) sells to 4 stores…
-
1
votes1
answer110
viewsHow to check if something has been passed to the php page?
It is even difficult to ask because I do not know if this is right, but I will try to explain it in the best way possible. I have a page where I will use the php case switch to decide the action…
-
1
votes2
answers233
viewsHow to make this consultation with JPA?
I would like two solutions to this question, one using a normal typedquery and the other using the criteria due to its great versatility for code. Here is my query: TypedQuery<Pessoa> query =…
-
1
votes1
answer47
viewsHow should the data of a table be selected through junctions?
When using the SELECT to obtain data from tabela_A by making a junction with the tabela_B, normally, and believing it to be the correct form, we use some of the commands JOIN. Ex: SELECT codigo,…
-
1
votes1
answer679
viewsConversion of Oracle to Sqlserver
Context: Currently I work in a system that uses the database oracle, but now I’m going to need the system to use sqlserver. My goal is to convert DDL and DML for sqlserver, I see there are some…
-
1
votes1
answer91
viewsHow to leave search field prepared to search for any term
I have a register of textures where the code is composed of numbers and sometimes with letters, for example: Código: 2564 Código: C-6551 I would like to have the search field prepared to perform the…
sqlasked 8 years, 8 months ago adventistapr 5,498 -
1
votes1
answer62
viewsLeft Join repeat tables
I’m trying to assemble a select that has the result below: With select below I can show the null in just one column. How could I make it work for 20? I have from item_1 to item_20 and the…