Most voted "database" questions
A database (its abbreviation is BD, DB, database) is an organized collection of data typically used to model certain situations. Use this tag if you have questions about designing a database. If this is a specific database management system, like Mysql, for example, use this tag instead.
Learn more…3,414 questions
Sort by count of
-
3
votes1
answer659
views -
3
votes1
answer97
viewsExpression nickname with SUM is not working
I’m trying to make a SUM in a query that performs some calculations. Follow the example: SELECT SUM ( (qtd - qtd_devolucao) * valor AS total) FROM produtos WHERE id_pedido = '47' I’m having the…
-
3
votes1
answer174
viewsGenerate number using Identity
Is it possible to generate a number before writing the record to the database? Use field identity do SQL Server 2014. Work with Delphi Berlin.
-
3
votes1
answer6636
viewsHow to calculate the average using conditions in SQL Server?
The question asks me to show the number of students with averages greater than 7, less than 7 or equal to 7 for some tables I have here. Thus showing: How to create this column of Description?…
-
3
votes2
answers64
viewsDatabase, display name via ID
Could someone help me. Have the following tables PLAYERS id name nickname status EVENTS id date local_id SCOREBOARDS id evento_id winner loser_id the winning and losing fields, save the player id in…
-
3
votes1
answer1018
viewsError converting from varchar to smalldatetime
In the query below the following error occurred: Conversion of a data type varchar into a data type smalldatetime resulted in a value outside the range. Looking at it, I realized that if I take the…
-
3
votes2
answers1649
viewsOptimize a data transfer from one table to another SQL SERVER
SQL SERVER Database I have two tables, one with 2 billion records and the other with 16 billion. I am copying the first to the second. Using the INSERT INTO table2 SELECT * FROM table1; Doesn’t work…
-
3
votes3
answers775
viewsHow can I make a copy of multiple tables in a new table using SQL SERVER?
I have several tables with the same number of columns. and I want to insert the records of these tables into a new table. Anyone have an idea? because I only managed to insert one and does not…
-
3
votes1
answer485
viewsSearch the bank in real time
How can I do in PHP so that when the user type in the search field it already appears the database records. For example, assuming that it is a register of cities, the user type "Field", should…
-
3
votes1
answer111
viewsUsing sql_cache in Mysql query
When I learned Mysql, I was recommended to use the expression sql_cache after the SELECT, something like that: "SELECT sql_cache * FROM tabela..." Since then I started to use this in my codes, but…
-
3
votes2
answers999
viewsWhich is more efficient, perform multiple queries or use JOIN?
I have a table X that has my user data, and I need to return to the client the data related to that user in the table Y and Z. I can do it using JOIN or: SELECT attr1, attr2 FROM Y WHERE X_id = id…
-
3
votes1
answer115
viewsWhy does bitmap indexing work well for low cardinality domains?
I have just read chapter 29 of the book Overview of Data Warehousing and OLAP On page 725 the author talks about indexing techniques to support high performance access, this technique is called…
-
3
votes1
answer98
viewsMount Query to last Google Datastore record
I’m working with the Datastore from Google and I’m unable to mount a Query to return what I need. Situation I have a Entity, keyed {"item": codItem, "item": id}, still within that Entity I have the…
-
3
votes1
answer53
views(SQL) Each property has multiple images and a cover image
Suppose I have a Real Estate table where a property can have multiple images. I have therefore another table, Images, with the url. I also have an intermediate table that makes the relationship N:N…
-
3
votes3
answers5999
viewsseveral values for a column in Where
Is there any way to put several values for a column in WHERE? For example product A was replaced by product B, product 2933 for the 4044, product 2599 for 7845, and product 5987 by 9432. Example:…
-
3
votes1
answer96
viewsBring results from two tables (INNER JOIN error)
I have the table secretariats with the following structure: And the worker table with the following structure: I related the worker table to the secretariats table through the following list: That…
-
3
votes1
answer152
viewsHow to allocate transactions or group by day?
SELECT COUNT(*) QTD_TRANSACOES, CD_RSP_RECUSA, SUM(VL_AUTORIZADO) VALOR_SOMATORIO, CASE WHEN MR.DS_MOTIVO_RECUSA IS NULL THEN 'CÓDIGO DE RECUSA NÃO CADASTRADO' WHEN MR.DS_MOTIVO_RECUSA = 'APROVADO'…
-
3
votes0
answers126
viewsDoubt in PHP database connection
I have a question in a code in PHP. My code is generating several alerts: And it seems to me that the same is not making connection with the database, because I am sending him to print some data and…
-
3
votes1
answer4972
viewsSELECT in VIEW generates sub-query?
I wonder if I make one VIEW with a simple query, whether the view call generates a new SELECT, ie a sub-SELECT totaling 2 SELECTS or whether it only points to SELECT from within the VIEW? I only ran…
-
3
votes1
answer1124
viewsConcatenate PHP date to insert into Mysql
Good morning, my doubt consists in the method of concatenation and creation of a Datetime to insert in a database. Having the variables: $dia = '2018-04-11'; $hora = '09:36'; The desired format is:…
-
3
votes2
answers4232
viewsCan I use a JSON file as a database?
I’m looking to start a project but I don’t want to create a database so I wonder if I could use a file json as a database.
-
3
votes4
answers1722
viewsHow to recover a value from within a tag in XML?
I have a table called SPDNFE with a column DsXML which contains all the contents of a Xml. Query: SELECT top 1 SPDNFE.DsXML FROM SPDNFE where SPDNFE.CdIdNFe =…
-
3
votes2
answers932
viewsGROUP BY SQL error
I have the following exercise: List the department code and name, newest and oldest admission date of each department, sort by department name. Here’s what I did: select d.department_id,…
-
3
votes3
answers1110
viewsHow to find "holes" in SQL Server tables?
I have a table with a column id (primary key, auto increment value 1). My application nay allows lines to be excluded, hence the expected query SELECT id FROM tbl ORDER BY id ASC that would be it:…
-
3
votes2
answers329
viewsGroup table data with INNER JOIN
I want to create polls on my website but I have a problem relating two tables. Questions are repeating. Table pergunta id_question = 1: what do you think of the Samsung S8? id_question = 2: what do…
-
3
votes4
answers3251
viewsSelect first name? - Select in bank
I have a table with the following names: João Goldy Alfredo, Gaby, João Antônio, Rodrigo, Maria Aparecida, Mario How can I get only their first name, and those who don’t have a last name, should…
-
3
votes2
answers244
views -
3
votes2
answers57
viewsHow to keep the variable with the same value in the database?
I have a question in the code below: <?php include "conexao.php"; $id = $_POST["id"]; $nome = isset((trim(ucwords($_POST["nome"])))) : (trim(ucwords($_POST["nome"]))) : $apelido =…
-
3
votes1
answer790
viewsCheck whether the field is null in java and mysql
How do I check if a database field is filled or null? Do you have a Resultset method that does this check? In this case it is a date field. PreparedStatement ps = connection.prepareStatement("SELECT…
-
3
votes1
answer3146
viewsTurn rows into a select column - PIVOT - SQL Server
I have an SQL query that returns the following result: Consultation +--------------------------------------------------------------------------+ | CONJUNTO | TIPO | FILHO | PAI | TIPO_CONTEUDO |…
-
3
votes2
answers334
viewsIs "inheritance" table a bad practice in this case?
In my database I need to store employees, customers and suppliers. Since all these share data in common, but not all the data, I decided to create a table pessoas with the columns in common: id //…
-
3
votes2
answers385
viewsSQL using sum
I have the following structure: | Data |Quantidade|QTCxVer|QTCxBra| |04.09.18| 10 | 1 | | |04.09.18| 30 | | 3 | |04.09.18| 40 | | 4 | |04.09.18| 50 | 5 | | |05.09.18| 20 | 2 | | |05.09.18| 10 | | 1…
-
3
votes1
answer84
views -
3
votes1
answer82
viewsIs it mandatory to list tables in a database?
I have a slight knowledge of the database and I know how to use it JOINfor certain SELECTs. I am mounting a simple DB where I have certainty absolute that a table has no relations with others. Is it…
-
3
votes1
answer523
viewsReplication of a database
I have read some articles on database replication and mirroring, but a doubt I still have, and I did not find a "concrete" answer would refer and update the database. For example: I have MASTER and…
-
3
votes1
answer82
viewsIs it possible to place an HMTL file within the data set?
It is possible to save an HTML file in a column BLOB inside the database and then display as part of the page in PHP? Why do this: it’s more of a learning experiment to compare whether it looks…
-
3
votes1
answer126
viewsHow do I change the order of entering the Mysql database?
I want you to insert something into my Mysql (Phpmyadmin) and place it on top of the last post. Example: Yesterday I inserted Nome: Pedro | Idade: 20 Anos and he was at the top by being the first to…
-
3
votes1
answer48
viewsSorting multiple columns
The sales table has the following structure: id_venda | nome_cliente | data_venda | data_agendamento | data_cancelamento | data_ligacao Where the "date" fields are all datetime. I would like to…
-
3
votes2
answers2282
viewsError with Insert in SQL Server: The Conversion of a varchar data type to a datetime data type resulted in an out-of-range value
Next I have to do a survey and implement a query in the database using Merge and I have to do it using one of the scripts used in class. The problem is that when I run the script the following error…
-
3
votes2
answers184
viewsBring sql record even if you don’t have the necessary accent
I need to bring a record called Vidraçaria in a survey, how can I bring this record by writing only Glassware in research? Or bring water seeking only agua The search works normally when the word is…
-
3
votes1
answer55
viewsIs there anything equivalent to Mysql’s "FOR UPDATE" in Sqlite?
As the title itself says, there is something equivalent to FOR UPDATE Mysql in Sqlite? Example: SELECT id FROM minha_tabela WHERE id=1 FOR UPDATE I own a query that uses a unique line lock within a…
-
3
votes1
answer1161
viewsHow to save a PDF file to the database and make it available for download?
I am developing a web application using Playframework, and I need a file that will be a kind of guide (documentation) for users who will use my application to be able to download or view by the…
-
3
votes1
answer527
viewsHow to capture camera image from your phone and send it to the server via Rest using Volley?
I’m developing an application MOBILE that communicates with my web application, the application developed in Android Studio and the web on Playframework. I created a form on APK that already makes…
-
3
votes1
answer32
viewshow to create a postgresql table? how do you use alter table and drop table? and what are the differences between Primary key and Foreign key?
People help me with postgresql studies.How do you create a postgresql table? how do you use the alter table and drop table? and what differences of key Primary and key Foreign ?
-
3
votes1
answer68
viewsMerge results in mysql
I have a database that already performed a query and got the following table: I would like to know how to assign zeroed positions, or replicate subsequent fields that have some defined value,…
-
3
votes1
answer1355
viewsPassword or invalid user when logging into oracle database (ORA-01017)
Good morning, everyone, I need to set up an environment for a course. For this I installed the Oracle database and SQL Developer. In the oracle database I have the SYS user working perfectly. The…
-
3
votes0
answers515
viewsWhat should I worry about when creating a Partitioned Table in SQL Server?
I was suggested to partition the main table of my system to improve the performance of some queries. The dev who made the suggestion suggested using the information from ano registry registration to…
-
3
votes0
answers233
viewsHelp with ABC curve creation in Mysql
I set up a select to know how many products were sold in a given period and the sale value of those products. Only I need to mount an ABC curve with the result of this select. Could someone please…
-
3
votes1
answer59
viewsDifferent ways to do a query that performs an SQL merge
I learned to do SQL queries with joins as follows: SELECT u.NOME, e.RUA FROM usuarios u, endereco e WHERE e.ID_USUARIO = u.ID ORDER BY u.NOME As you can see, the query searches the name of users and…
-
3
votes1
answer88
viewsIs there any SVN for database?
I have the following environment, an online database (Mysql) for production and several others (copies for each developer) used for local testing. Is there any program as well as SVN that performs…