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
answers14
viewsHow to insert data into sql without erasing old data?
Hello. I’m learning sql now, I’m trying to make a simple python code to store 4 data in sql database. But every time I stop the code and run it again, it erases the bank and starts again. I couldn’t…
-
-1
votes1
answer30
viewsTrigger to devalue apartment price if garage linked to it is excluded
I need to create a Rigger that devalues the value of the apartment when a garage linked to it is deleted, I have the following tables: create table apartamento ( numero varchar(5) not null, tipo…
-
-1
votes0
answers28
viewsPage does not take cities from the database, only the state
I have a page that selects the state in the database and after selected, it chooses the cities of that state, but can not get the cities, is only taking the state. Here is the main code that makes…
-
-1
votes0
answers23
viewsHow to group specific data
I made a precedent in which I am trying to group the items with the same id_request, but the answer I get at the time of running is, each separate product, even though it still has the same id.…
-
-1
votes0
answers25
viewsTo what extent is it advantageous to use Nosql?
I’m developing a little app. It does not have a very large amount of data initially, but it would store for example user data (login), images, and some information in text format. But I intend to…
-
-1
votes0
answers19
viewsHow to Select Field from a Table in Microsoft SQL Server Management Studio (SSMS) through C#?
I am making a login system, and for the login to be valid, I must read the value entered in txtNome (where the user will have entered the name he registered), save the text in a variable and perform…
-
-1
votes0
answers9
viewsFatal error : Undetected error: Call to a member function run() on bool in C:
The following error in my code is occurring: Warning : PDO :: query(): SQLSTATE [HY000]: General error: the mode must be an integer in C: xampp htdocs joel_php curso_hcode DAO sql.php on line 34…
-
-1
votes0
answers7
viewsConnection to the wordpress database does not work
A client has an error in the wp-config of the wordpresse message "Error establishing a database Connection", I looked and do not know what it can be...? code below: <?php /** * The base…
-
-2
votes1
answer627
viewsWhich attribute to use for database fields working with numbers from 0 to 5?
Needed to mount a table in Mysql, where the values recorded in this table will be between 0 and 5, what attribute types within the table field should be assumed? What kind of data do we report in…
-
-2
votes1
answer273
viewsColor in an SQL query
I would like to put one with in an SQL query for example: wp_usermeta.meta_key = 'first_name' or wp_usermeta.meta_key ='last_name' I’d like to put red here 'last_name' it is possible? Follow the…
-
-2
votes1
answer62
viewsDoubt SQL query
I need to make a Mysql query in the following situation: I have two tables announcements and Likes, when the user likes an ad a record is created in the Likes table with the user id and the ad id he…
-
-2
votes1
answer50
viewsQuerys MYSQL BELONGS
I need to make a query in the mysql, within the WHERE I need you to contain the COD_IDENT within a group. That is: COD_IDENT 5 6 7 My query need to return all results where COD_IDENT be equal to…
-
-2
votes2
answers70
viewsSyntax error when using UNION
Error: /* Erro SQL (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM pedido a, tipofornecimento b '…
-
-2
votes1
answer79
viewsCreate Table in SQL Server 2008
There is possibility to create a table of CAIXA that, for example, when placing the CODIGO of the product, pull the DESCRIÇÃO automatic, being in the table of PRODUTOS??…
-
-2
votes2
answers1947
viewsStress problem PHP and Mysql
I have a question regarding accentuation, specifically the return of Ç. My bank has the collation latin1_swedish_ci, I’m using the HTML tags: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0…
-
-2
votes2
answers152
viewsHow to make something expire after certain months in db?
I want to add a "license" for a purchase in my database, plus this license that my "customer" will buy will have an expiration date, let’s say he bought a license... INSERT INTO compras (userid,…
-
-2
votes3
answers493
viewsIs it bad practice to fill <select> <option></option> with data from the database?
It would be bad practice to use selects of HTML with items obtained through a database, even though they are dynamic (always occurring addition in the table that contain them). Example without a…
-
-2
votes1
answer116
viewsHow to validate some fields in SQL
I have the following SQL $contarperfilclienteinsuficiente = "0"; $sqlxmlperfilclienteinsuficiente = "select COUNT(CASE WHEN tipo = 0 THEN 1 ELSE NULL END), COUNT(CASE WHEN tipo <> 0 THEN 1…
-
-2
votes1
answer121
viewshow to fetch table values in C#
i have this following code, how do I return what is in the user field of the user table ? public int GetPerfilId(string username) { int result = 0; if(db != null) { DAL.Utilizador uti =…
-
-2
votes1
answer259
viewsControl virtual store stock
I am in a virtual store project and I have a question about the stock control process. Initially I’m doing everything on the table product where I have two camps: manage_stock and stock. Manage…
-
-2
votes3
answers926
viewsPHP-Mysql Error Return: Call to Undefined Function
Good evening, I’m trying to make a connection to the database. And mysql is returning the following error.: Call to Undefined Function mysql_connect_db() Follows my code: <?PHP // $servidor…
-
-2
votes1
answer65
viewsUpdate warning screen
I am developing a stock control system and box front and I intend to create a warning screen in the main form (can be with datagridview), where, if when selling a product and the same reaches the…
-
-2
votes3
answers181
viewsSum of a column is not giving the expected value
I have a fictitious table with two columns and some data in it, according to the image. When I run my SQL statement below, the result of the query is 22. Shouldn’t the result be only 12? I couldn’t…
-
-2
votes1
answer49
viewsWhat do you do when this happens?
I am working on a system in which I must register several data from a form in different tables using mysql. It works like this: The person makes a registration and in the same form requests a…
-
-2
votes1
answer444
views -
-2
votes1
answer39
viewsProblem in Table Creation
I’m trying to create a table, and I can’t find the error in its creation: CREATE TABLE Beneficiarios ( Ano year(4), Homens number(4), Mulheres number(4) );
sqlasked 7 years, 4 months ago Dario Ribeiro 11 -
-2
votes1
answer58
viewsList Database with Java or PHP
I wonder if there is any way for an application to show all databases of a connection? I currently use the command: select * from information_schema.TABLES;…
-
-2
votes2
answers263
viewsjoin sql tables without Primary Keys or Foreign Keys common to 2 tables
I have to do an SQL search in several tables. I need to relate the two through a common "id" but I do not know how because I do not have declared Primary Keys or Foreign Keys. Follows code snippet:…
sqlasked 6 years, 11 months ago Luis Aparicio 1 -
-2
votes1
answer483
viewsListing and Counting Rows from a table in Mysql
I am trying to make a list of users who have logged in and at the same time a count of how many times each user has logged in, from log logins in a table, I can not explain very well, so will an…
-
-2
votes1
answer226
viewsC# - Pass only numbers in a field formatted for currency
I have an application that presents me in a textbox the value of a course enrollment: string mensalidade = string.Format("{0:C}", Convert.ToDouble(leitura["Mensalidade"]));…
-
-2
votes4
answers4554
viewsGROUP BY and ORDER BY Mysql
When I send the Query: SELECT * FROM tabela WHERE id_cliente = '$id_cliente' ORDER BY ano DESC Duplicated values are returned because there are duplicate values in the table. But I want to return…
-
-2
votes1
answer740
viewsDelete table record with foreign key
Where is the Error? DELETE FROM postagens WHERE id='$p_id' AND u_id='$u_id' SET FOREIGN_KEY_CHECKS = 0; Clarifications: p_id = id of posts(primary key) u_id = user id(foreign key)…
-
-2
votes1
answer451
viewsSQL command in MYSQL
I’m creating a DBA and I need to make one CHECK on an index of my table produto, but I’m using Mysql and I’m having a problem with the syntax. Follow the example: CREATE TABLE produto( Cod_produto…
-
-2
votes1
answer32
viewsBasic report through SQL
Good afternoon, I am doing a system of evaluative questionnaires, where has several questionnaires with various questions that refer to a questionnaire, which can be opened or closed. In the table…
-
-2
votes2
answers541
viewsIF/ELSE in SQL (Control Structures)
Okay, I’m reading some articles on SQL control structures but I’m not getting a lot out of it, someone could explain how it works in a summarized form?
sqlasked 6 years, 5 months ago Davi Alves 11 -
-2
votes1
answer38
viewsI can’t get the date on the chart
I’m doing the following command: SELECT h.h_dia FROM hh h WHERE h.h_dia = 20180621 GROUP BY h.h_dia
-
-2
votes1
answer145
viewsCheck if value is in a column
I need to check if a value is in a column in the comic book. My column is separated by commas, thus: 1,2,3,4,5. So I would like to know how to check if the value 2, for example, is in any row in the…
-
-2
votes1
answer286
viewsHow do I make messages in Javascript etc, when logging in a warning appears?
I want to know a code that when the person clicks on an OK button to log in a warning: "You are logged in!". If a warning does not appear: "You are not in the system, enter your Access information…
-
-2
votes1
answer56
viewsReordering Autoincrement in SQL
Eae guys, like I created an ID table with Auto Increment, checking the table ví Bugou, have any SQL commands that reorder from 1,2,3,4 to last? just more for the sake of reorganization. Thank you.…
-
-2
votes2
answers56
viewsDifficulties in making select
Wanted a help on how to solve the last 3 selects down. Recalling that the reports that contain the item "Total quantity" demand the total quantity of the product taking into account all the orders…
-
-2
votes4
answers177
viewsCount(*) returning null
I have this query: SELECT COUNT(*) FROM USER_IND_COLUMNS WHERE TABLE_NAME = UPPER('TABLE') AND COLUMN_NAME IN (UPPER('ANO'),UPPER('MES'),UPPER('DIA'),UPPER('HORA')) GROUP BY INDEX_NAME HAVING…
-
-2
votes3
answers422
viewsUpdate in the same table
I have this table like this: CODIGO_AULA DATA_AULA TURMA ----------- ---------- ---------- 1 2018-01-19 MEC-001 2 2018-01-19 MEC-001 1 2018-01-20 MEC-001 2 2018-01-20 MEC-001 1 2018-01-21 MEC-001 2…
-
-2
votes1
answer63
viewsSelect COUNT > 10K in C# and SQL
I would like to select in records greater than 10 thousand and delete after. select count (FuncionarioID) > 10000 FROM FuncionarioLog; How should I select correctly?…
-
-2
votes1
answer259
viewsSQL SCRIPT PROJECT
Good afternoon, I have this project as a college job, I wish someone could give me a light, telling me if there is something wrong, or something I can improve. Follow the print of what is requested,…
-
-2
votes1
answer237
viewsI cannot connect the Mysql Nodejs database
It should show the table data on the screen, but does not return anything. Where I am missing? module.exports = function(app){ app.get('/noticias', function(req, res){ var mysql = require('mysql');…
-
-2
votes2
answers250
viewsMysql - INNER JOIN - INDEX
Guys, I got one query here very simple with JOIN, Because banks have a lot of records, I need to index... But I’m getting it for kct... What is the best way to index in a JOIN? (That one query takes…
-
-2
votes3
answers793
viewsHow to delete only records from a field of my table in SQL
Good morning, I would need to delete only those registered from a field of my table. In the case I have the product table and in it has the field dtsanitation and in this field had records. I would…
-
-2
votes1
answer43
viewsWhat does this cursor/pointer syntax mean in SQL?
What does this SQL cursor/pointer syntax mean? SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,…
-
-2
votes1
answer59
viewsSQL Sorting and Grouping
How could I sort this table by placing it in order of the Field name column not being in alphabetical order and following the Right to Right field. For example, each field name has several different…
-
-2
votes2
answers47
viewsI a select where the same is starting to get too slow, Would you have any solution to improve your speed?
SELECT pessoafisica.PessoaFisica_Nome, filiados.`Filiado_MatriculaEmpresa`, filiados.`Filiado_RetornoSiape` AS observacoes, Filiado_MatriculaEmpresaDigito, lotacao.Lotacao_Descricao, (SELECT…