Most voted "mysql" questions
Mysql is a relational database management system (RDBMS) that functions as a server, and provides access to multiple users simultaneously. Your source code is available under the GNU General Public License.
Learn more…10,264 questions
Sort by count of
-
2
votes1
answer161
views2 FK to 1 PK
I want to connect the 2 FK of the credit card table and bank bill to the Id_payment table plus the following error arises: Error Code: 1022. Can’t write; Duplicate key in table '#sql-900_e' I have…
mysqlasked 7 years, 9 months ago user63891 -
2
votes2
answers485
viewsINSERT INTO with Mysql filter
I am trying to create an INSERT INTO in an X table by making a filter in table Y, but I get a syntax error. I’ve researched what could be wrong, but not found. INSERT INTO products ( SELECT * FROM…
-
2
votes1
answer231
viewsUse ON UPDATE CURRENT_TIMESTAMP when changing specific field
Example scenario Table: usuarios Campos: id, nome, sobrenome, senha, timestamp_alteracao Question The field timestamp_alteração, should only be updated when the field senha is amended. Doubt There…
-
2
votes1
answer3849
viewsHow to delete primary key (PK) in Mysql?
I have the following table in Mysql: The id column is primary key. I would like to remove the primary key from this table. How can I do this? Thank you.…
-
2
votes1
answer59
viewsConditions different from the same column
I have a table called anuncios: id | nome | finalizar | datafim 1 | teste1 | N | 0000-00-00 2 | teste2 | S | 2018-12-05 I’d like to make a SELECT listing only records where the column value…
-
2
votes3
answers76
viewsHow an array comes from the database in an input
<input type="text" class="form-control" name="lanches" id="lanches" value="<?php echo $resultado['lanches']; ?>" > I have that above input where it receives that array that is inside the…
-
2
votes2
answers502
viewsSQL with 2 of multiple conditions
I’m having trouble making a Select that meets 2 or 3 conditions of several selected, for example: Conditions: - Cidade Tal (São Paulo) - Nome Tal (João) - Sexo (Masculino) - Fumante (Não) - Carro…
-
2
votes1
answer79
viewsQuerys have stopped working
I recently made a change to the table and after that SELECT and INSERT INTO stopped working. At first the INSERT INTO could not include data in the last column that includes (centid), returned…
-
2
votes4
answers6441
viewsFormat Real value (br) to decimal (10.2) mysql
Good afternoon, you guys! How to format Real value (br) to mysql Numeric(10.2) using php number_format? I tried to use: $num="89,90"; ou $num="1.089,90"; number_format($num, 2, '.', ''); But this…
-
2
votes3
answers140
viewsGROUP BY last registration per month and year how to do?
I’m making an appointment at the bank, follow my table below id | valor | mes | ano | 1 39.69 3 2017 1 7.69 3 2018 3 9.69 4 2015 3 3.69 2 2016 2 5.89 3 2017 2 39.69 8 2018 need to bring the result…
-
2
votes3
answers264
viewsSelect Group by Month
SELECT dataVen, Sum(valorTotal) as valorTotal FROM cad_cr2 Group by MONTH(dataVen) The above query returns the following values: I wish it were so, grouped by month: I have done many researches and…
-
2
votes1
answer929
viewsmysql Workbench error
I’m trying to make a database for an academic project, I’m doing the model on the Workbench and then I try to synchronize with phpmyadmin, it turns out that when making the Foreign Keys the same…
-
2
votes2
answers686
viewsDistinguish equal fields in a SELECT with LEFT JOIN
In a SELECT done in two tables with similar fields I would like to distinguish the field of each table when displaying the results. For example: $sql = BD::conn()->prepare("SELECT a.*, b.* FROM…
-
2
votes1
answer425
viewsSelect last records in ascending order
I know there are many topics with this subject, but none of them have been able to help me so far. I need to select the last 8 records so that they are organized in ascending order. Example of the…
-
2
votes1
answer364
viewsHow to calculate the discount average in Mysql
I need to calculate the discount average per product in my table in Mysql, but my code is only running on average, how can I get it to give me the product and the discount average on top of this…
mysqlasked 5 years, 10 months ago Lucas Tadeu 71 -
2
votes4
answers4228
viewsHow to perform query with some null values?
The SQL below returns the values correctly only if the field data_emissao be as nonzero in my BD table (independent if the parameter cliente was passed or not), but I wish to return the values where…
-
2
votes2
answers135
viewsHow to sort a select by bringing results of 2 in 2
I am creating a system where the user informs the name and time of birth. I would like to know whether the following question can be resolved: I have the following table: Having the name and time of…
-
2
votes1
answer66
views2 Groupby in a Mysql query
In Mysql I have a login table with the field day and User ID: 28-01-2019 - a 28-01-2019 - a 29-01-2019 - a 29-01-2019 - b 29-01-2019 - b 30-01-2019 - a 30-01-2019 - b 30-01-2019 - c What I need is…
-
2
votes2
answers572
viewsmysql with single PDO result
I’m trying to create a query as follows: I have a table in the database with this structure: name | address | status The status field only has 2 types of values 1 or 0. I want to count all records…
-
2
votes1
answer266
viewshow to perform a SELECT COUNT faster!
I need to perform a query to know a total of operators I have. However the table has almost 18 million records, and it is taking a long time to return almost 3 minutes, and this is because I am…
-
2
votes1
answer2583
viewsAccess denied for user 'root'@'localhost '- Application connects via command but not in Wildfly 10
Settings: Wildfly server 10.1.0 Mysql 14.14 Mysql-Connector- 8.0.15 Hibernate 5.2 Permissions granted to the user: GRANT ALL PRIVILEGES ON bd_billings.* to root@localhost;FLUSH PRIVILEGES; ALTER…
-
2
votes1
answer64
viewsGroup result through a conditional
I wonder if in Mysql or any other Bank you have the possibility to use GROUP BY with a conditional. I will try to explain I have a status column that can have the value true and false, would like to…
-
2
votes4
answers724
viewsLogical doubt: How to find out if an hour is between the hours interval (independent of the day)
Regardless of the time, I need to find out if a time is between the initial and final hour interval, given the 24-hour format. The logic can be both in PHP and MYSQL, since either way should stop a…
-
2
votes3
answers336
viewsCatch Fatherless Children in a MYSQL hierarchical structure
I have a table with the following structure |id|parent_id|name| At some point, due to a programming error, some parents were erased and their children remained. So I need to create a query to fetch…
mysqlasked 5 years, 8 months ago Laercio Nunes 113 -
2
votes3
answers202
viewsSql query bring repeated result
How do I list only the sector column that has repeated data? in case, just show the sector 150 SELECT setor,count(quantidade) as quantidade, usuario FROM arquivo_coletor GROUP BY setor,usuario ORDER…
-
2
votes1
answer64
viewsQuery SQL summing fields from one table with criteria from another
I would like to do a query that adds for example the name of the equals by date (here I will put the period, for example 01/03 to 22/03), the problem that I have two tables, one of individuals where…
-
2
votes1
answer193
viewsJSON in PHP with existing fields printing as Null, how to resolve?
I have a SELECT that is not returning some fields, such as "Notes". In the following image I list the array and see that it is like "Null" the field remarks: My return SQL is this: <?php…
-
2
votes2
answers1262
viewsHow to run mysql database using shell script if the base name has "-"
On the server there are some databases with the name modelo-submodelo (this is the name of the database, created with "-" same). When I execute a command like: mysqldump -h"$DBHOST" -u"$DBUSER"…
-
2
votes2
answers314
viewsDatasource Configuration Error in VS Community 2015 C# + Reportviwer + Mysql
good afternoon. having a tremendous difficulty solving this problem. I am in the distribution phase of an App and exactly today I had a serious problem. Generate a report Using Riportviwer and Mysql…
-
2
votes1
answer504
viewsI need to select sequences of numbers in a field of a table column
I have a 'Text' column in my 'process' table. Text consists of a VARCHAR (220), in this text I need to identify a specific word pattern. In this case a sequence of numbers with a "-" to separate:…
-
2
votes0
answers71
viewsAccess to global variables in Mysql Server
It is possible to restrict access to global system variables for a particular user? The intention would be not to allow it to have access to variables such as: @@GLOBAL.HOSTNAME,…
-
2
votes1
answer38
viewsCorrect creation of tables
Given my classes where Encomenda inherits from Objeto: @Entity @Table(name = "objeto") @XmlRootElement(name = "objeto") @XmlAccessorType(XmlAccessType.FIELD) @AllArgsConstructor @NoArgsConstructor…
-
2
votes0
answers68
viewsDoubt: Web Sockets and how to use
I was seeing this question link. Then I did not read in the answer about nodejs and researched about, but I did not understand much. How to apply this technology (nodejs)? I am developing a site in…
-
2
votes1
answer486
viewsCompare values of 2 arrays with PHP
Dear colleagues, I have the following situation: BD 01 ID | DESCRICAO | DRADS 1 | REGISTRO1 | 1,2,3 2 | REGISTRO2 | 1 BD 02 ID | DESCRICAO | DRADS 1 | REGISTRO1 | 1,2 2 | REGISTRO2 | 1 And I need to…
-
2
votes3
answers180
viewsMysql - Create an alias by concatenating multiple fields
Is it possible to create an alias by concatenating other fields? Ex: SELECT u.nome, u.sobrenome AS nome_completo FROM usuarios u In the example, I want to concatenate u name. and u surname. and…
-
2
votes2
answers88
viewsVARCHAR FOR NUMBER
I have a column (value) in MYSQL in varchar, and in it I store whole or broken numbers, like this: 1.1 2 3.99 4.2 2.345 In the query I need to know when a number is (greater or equal) and (less or…
-
2
votes1
answer173
viewsMysql - Problems changing the "max_execution_time" variable
I have a Mysql Server 5.7 installed on a Windows server, when I change the variable "max_execution_time" to 6000, when I run the query below with ODBC to confirm that the change was made: show…
-
2
votes1
answer19
viewsConverting columns into rows by concatenating the results
I have the following select : SELECT pedido, item FROM pedidos How do I get the result of it in columns and step to row concatenating with -? Example: Upshot pedido item 1 batata 1 arroz 1 feijão 1…
-
2
votes1
answer255
viewsHow to make a weekly mysql query
Good morning everyone! I would like a Help!!! I am in doubt of how to make a weekly mysql query, starting on Monday and ending on Sunday, and the data will be inserted every day, and from the data…
-
2
votes1
answer350
viewsHow to concatenate a variable plus a message in the "Insert"?
Concatenate a variable and a message in the insert? Example: declare a int; set a = 2; insert into tb_usuario values ('a' + 'fez tal coisa');
-
2
votes1
answer253
viewspass input data to mysql database table
People help me there, I’m creating a user manager with level system. however I am not able to pass a value of the variable defined by input() to the INSERT. please help me. code: def…
-
2
votes1
answer144
viewsMysql query grouping the results in the case
I have the following appointment: SELECT DAY(o.data_fechamento) AS DIA, u.nome AS TEC, COUNT(*) AS TOTAL FROM ocorrencias AS o LEFT JOIN sistemas AS a ON a.sis_id = o.sistema LEFT JOIN localizacao…
mysqlasked 7 years, 7 months ago Chefe Druida 1,086 -
2
votes1
answer349
viewsMysql Split by ZERO, SQL_MODE = 'TRADITIONAL'?
I’m with the SQL_MODE of MySQL as TRADITIONAL in the version is 5.7.18 and according to the documentation this way would make the MySQL operate in the same way as other banks, for example SQL…
-
2
votes1
answer312
viewsMysql How to return only part of the result of the FULL-TEXT query
Let’s say I have this text stored in a table in my database: Lorem ipsum dolor sit Amet, consectetur adipisicing Elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad…
-
2
votes1
answer369
views"mysqli_connect" does not work
I am unable to use the "mysqli_connect" function. Can anyone help me? You are returning the following error: Fatal error: Constant Expression contains invalid Operations in…
-
2
votes2
answers418
viewsProblem with Table UPDATE based on summation of another table
Greetings to all of the forum! Like everyone who starts learning Mysql, we come across relatively simple problems but we can’t solve. I created the INFO_PACOTES table that stores information of…
-
2
votes1
answer79
viewsPick all levels of product categories
I have a question. I have a table of categories: CREATE TABLE `categorias` ( `id` int(10) UNSIGNED NOT NULL, `parent_id` int(10) DEFAULT NULL, `lft` int(10) DEFAULT NULL, `rght` int(10) DEFAULT…
-
2
votes2
answers226
viewsLaravel and Sqlite database
Think of me, you have server Laravel with a Sqlite database configured, access to this database in thesis is to be faster, since it is on the server itself. Follow the example: user -> server…
-
2
votes3
answers480
viewsHow do I know and count the number of rows in an SQL query with Laravel?
$teste = DB::table("cnaes") ->select("id") ->where("cnpj", $cnpj) ->where("cnae", $cnae); How can I know how many lines were affected by this query?…
-
2
votes2
answers666
viewsDELETE WITH LEFT JOIN
I’m having an error trying to execute this command: DELETE doacoes FROM doacoes LEFT OUTER JOIN animais ON animais.idAnimal = doacoes.idAnimalDoacao WHERE animais.idAnimal = doacoes.idDoacao; I want…