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
answers3503
viewsHow can I count fields that are NULL?
I’m using this query: I would like to know how to count these fields that have no records. Here returns 0. But I have some null records. What I do? SELECT DataFim, COUNT(DataFim) AS QTD FROM…
-
1
votes0
answers410
viewsStore array in database and recover using one of the array information
I need to develop a system where I capture the selected data from a checkbox and insert everything into a array, I believe this is the most appropriate method for storing, and then send it to the…
-
1
votes2
answers570
viewscmd.Commandtype = Commandtype.Text - Pq use?
Good morning guys. I’m populating a grid, and after searching the internet, I saw that some use the command: cmd.CommandType = CommandType.Text; My doubt, is, why use? what’s the difference? I did…
-
1
votes2
answers377
viewsHow to find the second largest number
I need to search the photo with the second highest salary <?php $host = "localhost"; $username = "root"; $password = ""; $db = "imagem"; mysql_connect($host,$username,$password) or…
-
1
votes1
answer294
viewsSum and mean sql table in java
I’m trying trouble with something I think until simple, but I don’t know which command I should run to do this. All right, here we go: I have a table (let’s call MOVIES) ...and this table has 3…
sqlasked 8 years, 4 months ago Joao Paulo 7 -
1
votes2
answers245
views -
1
votes1
answer66
viewsBKP Sqlserver does not run when executed by a trigger(Trigger)
I have a trial that runs a bkp from my database. If I run it by Sqlserver the bkp is normally performed But when I call for a Rigger, another trial or application the bkp is not realized, the folder…
-
1
votes1
answer77
viewsMysql - How to get the table name where the result came from?
I have the following mysql code: (SELECT * FROM entrada WHERE idUsuario = "1") UNION (SELECT * FROM saida WHERE idUsuario = "1") It’s all working but I need to know which of the 2 tables the result…
-
1
votes2
answers823
viewsHow to create a FOREIGN KEY using uniqueidentifier in SQL Server
Hi, I’d like a hand. I have a table on SQL Customer call, which has as primary key a type uniqueidentifier Ex: Create table Cliente ( ClienteID uniqueidentifier not null, Nome varchar(50) ) I’d like…
-
1
votes1
answer808
viewsFormat dates in sql
I have a program in c# (Visual Studio) of registration that contains a textbox to receive a date. Knowing that SQL records the date in American format, how can I make the user to enter the date in…
-
1
votes1
answer622
viewsDblookupcombobox listfieldindex Setting the index the combobox comes empty
I have a problem with Dblookupcombobox, even setting the value of listfieldindex , he is not bringing the item to the combobox cbcPais.ListIndex := 1;
-
1
votes1
answer1657
viewsProblem with id AUTO_INCREMENT in SQL
I created a table in Mysql Workbench with the following settings: CREATE TABLE teste ( id INT AUTO_INCREMENT, nome VARCHAR(50) NOT NULL, email VARCHAR(40) NOT NULL ); And when I try to insert data…
-
1
votes1
answer330
viewsWhile returning duplicate data
Good morning Guys, I have this query $query = "SELECT p.*, c.nomeCategoria AS categoria FROM produto AS p INNER JOIN produto_categoria AS c"; $dados = mysqli_query($con, $query) or…
-
1
votes3
answers227
viewsHyphenate when value is 0 in select
How can I do in the mysql one query (SELECT) so that when the value is equal to 0, replace it with hífen(-). Field of value: int.
-
1
votes1
answer1595
viewsGeneral error: 1449 when fetching Mysql Database records
I am getting the error below while doing SELECT: SELECT * FROM vn_horario_view; SQLSTATE[HY000]: General error: 1449 The user specified as a Finer ('root'@'localhost') does not exist How to resolve…
-
1
votes1
answer44
viewsConfirm Code and go to login page
Friends I’m new in PHP + sql help me here : -- -- Estrutura da tabela `verified_user` -- CREATE TABLE IF NOT EXISTS `verified_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `email` text NOT NULL,…
-
1
votes3
answers89
viewsSQL - Doubt in a query
Thanks to the help of Motta I managed to arrive in a satisfactory query but I ran into another question because, I need to list only the smallest record for cod, and count the amount of the column…
-
1
votes1
answer192
viewsSET ENABLE_BROKER taking too long to run
I executed the command ALTER DATABASE [Banco] SET ENABLE_BROKER; but it’s been running for over 20 minutes and counting. It would have a faster way to execute?
-
1
votes2
answers1277
viewsCalculation of hours with php
How to calculate the time the person entered and the time the person left minus the interval and display the total of hours they gave? For example if a guy made the following schedule: 07:30 12:00…
-
1
votes0
answers45
viewsGroupby making query get very slow
Good afternoon guys, I’m making a query in the bank where everything goes well, however when I use the "groupby" this query is very slow, very slow even, example, just take the line of the groupby…
-
1
votes0
answers49
viewsLoad database table by system session
I am developing an application, where one of the modules is the registration of products, and within this register, I have the tax part. In this fiscal part, I have to define an NCM, and according…
-
1
votes1
answer30
viewsField set_base NULL > SQL compliant
Reference issue: Delete sectors and their descendants - PHP I have the following SQL: CREATE TABLE IF NOT EXISTS `setores` ( `set_cod` int(10) NOT NULL AUTO_INCREMENT, `set_base` int(10) NOT NULL,…
sqlasked 8 years, 3 months ago Sr. André Baill 6,946 -
1
votes1
answer588
viewsIs it possible to leave connectionString dynamically?
I’ve read something and I know it’s possible to leave one connectionString dynamically in an ASP.NET MVC application. However, it is possible to create n connections where each authenticated user in…
-
1
votes1
answer3121
viewsCreate dynamic chart using mysql and Highcharts
Guys I’m trying to create a chart using Mysql and Highcharts on a Xampp local server. However, when running index.php only the source code of the page is displayed, not generating the chart. Below…
-
1
votes1
answer59
viewsCalculation of string occurrence
I have a table with 3 columns id, nome and voto. They’re populated with a lot of records, and I need a calculation to return the name with best "balance" of votes. The column voto can only receive…
-
1
votes1
answer184
viewsSearch PHP + SQL does not find results without typing the "-" hyphen
Hello! I have a search for automotive products where the user can search for the company code, original code, product line, automaker or vehicle. This system is working if in the search field I…
-
1
votes1
answer252
viewsCompound update
I have a table pessoas where, I have several fields referring to the person’s registration, One of these fields is the PES_NUMERO, which is nothing more than the code of the person in the system,…
-
1
votes1
answer82
viewsSearch records for a given day of the week
Staff I have the following select set temp = Conn.Execute("SELECT * FROM tbl_estacionamento ORDER by id asc") I have a table called date where I record the day of registration of information, I…
-
1
votes1
answer923
viewsSQL query to return only if capitalized
I would like to make a query in a column and that the return is only the uppercase words that correspond to the searched criteria (user input), no matter if the criterion was typed in uppercase or…
-
1
votes1
answer4141
viewsChecking that the value of the database column contains only numbers in select
I need to find out if the value of a given column of the database contains only numbers in the select itself, because if it is numerical, I need to display the value of another column. I use an…
-
1
votes1
answer104
viewsProblem using Sql LIKE in Angularjs
I have been a few days having trouble searching my app using AngularJS and today I was able to discover the reason: During the consultation SQL with LIKE, it is simply not receiving the parameter as…
-
1
votes2
answers282
viewsRegular Expressions in Oracle
'Select from CITIES tables only records with composite names separated by a single space' TABLE CIDADES ID CIDADE 01 SAO PAULO 02 RIO DE JANEIRO 03 SAO CARLOS 04 TAUBATÉ 05 SÃO JOSÉ DO RIO PRETO The…
-
1
votes2
answers531
viewsError 1093 in Mysql
Follow my Mysql code: create schema if not exists Faculdade; use faculdade; create table if not exists Alunos ( RA integer UNSIGNED not null, senha varchar(15) not null, nome varchar(100) not null,…
-
1
votes2
answers323
viewsSyntax error in SELECT WHERE using ADO.Net parameters
Someone understands this mistake and gets a solution? Code: OleDbConnection ConSelect = new OleDbConnection(); ConSelect.ConnectionString = Properties.Settings.Default.dbInvoice; ConSelect.Open();…
-
1
votes1
answer187
viewsAverage values where fields are equal
I have a table, in bank mysql, that receives some data regarding evaluations. How can I calculate the average of these evaluations directly on query, based on the question? I tried several ways,…
-
1
votes3
answers14296
viewsExport SQL Server query to CSV file
I need to somehow export the result of my SQL query to a CSV file. However, it has to be directly via SQL or VBS. Or else, all database table data can be exported to CSV.
-
1
votes1
answer340
viewsOracle End of file when running
I’m getting the following error message when running this trial *Encontrado simbolo "end of file" quando era esperado:* DECLARE -- LOCAL VARIABLES HERE I INTEGER; BEGIN FOR NCM IN (SELECT * FROM…
-
1
votes0
answers92
viewsHow to create a dynamic query with Left Join?
How can I leave this query dynamic , she is already working only that she only lists one semester each year and wanted her to list two, like when I select the first she lists the first and when I…
-
1
votes0
answers126
viewsConnect Sql Server Express 2014 with Visual Studio 2015
I can’t make the server name appear in Visual Studio, I have the firewall disabled and I have checked that the server is active, please help me Thank you in advance.…
-
1
votes2
answers904
viewsGenerate empty row (null) in sql server
I don’t have much knowledge of sql, but I need to do the following procedure: User gives a number. Sql generates the amount entered by the blank/null record user. After generated the blank records,…
-
1
votes1
answer3398
viewsForeign Key Sql Server
I have a question about Foreign key in the following situation: Tehno table UF, with 3 columns: ID_UF (PK), Cod_uf (int) and Descuf (nvarchar(50)) I have another table called IDE, with 3 columns:…
-
1
votes1
answer602
viewsExchange accented characters for accented characters
There’s some kind of method of me making a replace in characters based on CASE? I’m looking for something like this: UPDATE foo SET bar = SUBSTRING(bar, "Ã","ã"); -- se o caracter for LOWER -> ã…
-
1
votes1
answer266
viewsUsing Inner Join correctly and aggregating results
In my comic book, I have 4 tables: Aluno, Ano, Matérias and Nota. They are mounted as follows: Tabela :: Colunas ---------------------------------------------------------- Aluno :: AlunoID |…
-
1
votes1
answer123
viewsSql - Database Modeling
I would appreciate your help. I don’t know how to create tables in the SQL database My problem is this: I have a user with a request with several items. I already have the table users and products…
sqlasked 7 years, 7 months ago Sergio Guerjik 233 -
1
votes1
answer46
viewsSQL query using order by filtering by log
I have the table: | cod | hora | produto | Amostra | Min | Max | |-----|-------|---------|---------|-----|-----| | 1 | 08:00 | 96722 | 1 | 100 | 200 | | 2 | 08:23 | 96721 | 1 | 90 | 90 | | 3 | 08:50…
-
1
votes0
answers151
viewsCreate new user in the database via Rails C
Help me where the error is occurring, because I am not able to identify pq the field is not being recognized. Rails c u = User.new(email:'[email protected]', registration:192536, password:'changeme',…
-
1
votes0
answers612
views -
1
votes1
answer619
viewsSelect that does not return SQL blank
select 'TEM' AS InSituacao from GTCLogist where NrPlacaCarreta = '' and ID <> '35514' and year(DtBase)=year(GETDATE()) and MONTH(DtBase)=MONTH(GETDATE()) and DAY(DtBase)=DAY(GETDATE()) I have…
-
1
votes4
answers541
viewsConcatenate 2 PHP variables into SQL statement
I am developing a PHP system with Oracle and to "optimize" an update, I would need to concatenate a variable (with values from 1 to 3) in the name of the variable that I will pass in the…
-
1
votes1
answer62
viewsHow to group notifications
I want to make a system of notifications that come together when they’re the same type, like the ones on Facebook. For now I have the table with the following columns: user_id (person receiving the…