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
-
6
votes3
answers14615
viewsHow to remove a Foreign key in mysql?
I need to edit a table, but I cannot remove it. I need to remove Foreign key, however, all commands I tried did not work. I’m currently trying to alter table tabela drop foreign key nomefk And the…
-
6
votes1
answer61
viewsMysql function does not merge equals
I have this query for Mysql: SELECT email, COUNT(*) AS Vezes FROM automovel GROUP BY email HAVING COUNT(*) ORDER BY `data_cadastro` ASC It groups all the same emails together, and shows how many…
-
6
votes2
answers2211
viewsHow to save images in the database using spring boot?
I’m having trouble saving images from a form in the database. Does anyone know how to save an image in the Mysql database using spring boot? I’m learning this technology now, so with this…
-
6
votes1
answer100270
viewsHow to resolve Call to Undefined Function mysql_connect() error
I’m doing an IT inventory for registration and I want to connect to the database, but it’s giving this error: Fatal error: Uncaught Error: Call to Undefined Function mysql_connect() in C: xampp…
-
6
votes2
answers1324
viewsReturn 0 when SUM is NULL
When you find no results you return to me NULL, how can I make the search return me 0 when it is NULL? SELECT SUM(coluna1 + coluna2 + coluna3) FROM table WHERE nome='funalo' AND MONTH(data) = 09 AND…
-
6
votes2
answers1510
viewsHow to view the last 30 days of a query
I’m trying some alternatives to show only the records of the last 30 days, but I couldn’t make it work, the query I have is like this: SELECT comunidade.descricao AS nomeunidade ,comcargo.descricao…
-
6
votes2
answers263
viewsHow do I make mysql_num_rows of various results
Well, what I want is this: I have 1 table designated by items, in this table I have 4 columns: nomeitem iditem (Single id) numerobot What I intend to do is: I want to do a mysql_num_rows of all…
-
6
votes2
answers1113
viewsHow to return the most appearing words in a column?
I have this table below which has two columns, being id and description: CREATE TABLE myBigTable ( id INT(11) AUTO_INCREMENT PRIMARY KEY, description TEXT NOT NULL ) After entering some records, I…
-
6
votes1
answer130
viewsDifference Between Using "FROM Table, Table2" X "Join Table ON Table2"
Considering the two forms of union of tables through a join(anyone): SELECT Tabela.A, Tabela.B, Tabela2.C FROM Tabela LEFT JOIN Tabela2 ON Tabela.Id = Tabela2.TabelaId And a union using from SELECT…
-
6
votes2
answers120
viewsApproximation mysql filter
I came across some cases where users reported me not in the database, certain clients, I noticed that it is common to abbreviate the middle names or the absence of them, for example: Name: João…
-
6
votes2
answers978
viewsCheck if user name is unique in real time
Hey there, you guys! Currently, to check if a username is unique, I do it in the most basic way. Sending the POST to a PHP page that checks in Mysql, only then returns the error. php.: <form…
-
6
votes1
answer430
viewsUse missing ids
After seeing this question I have remembered a problem I have encountered several times: Let’s assume that there is the following table: Fruta ----------- 1 | Maça 2 | Banana 3 | Pêra Should it…
-
6
votes1
answer419
viewsHow to rename a Constraint in mysql?
I created a Constraint primary key in my table as follows: CONSTRAINT PK_user_type PRIMARY KEY(id) But now I need to rename it: CONSTRAINT PK_type PRIMARY KEY(id) Based on this, I have the following…
-
6
votes3
answers475
views -
6
votes3
answers1491
viewsMYSQL and REGEX Phone Number
I need to select records that have in the middle of the phone numbers text to delete (automatic moderation). It’s a forum, people every day comment and put phone numbers in the middle of the…
-
6
votes2
answers256
viewsConcatenate columns and return the relation by SELECT
Suppose I have the following tables and their relations: Tabela A Col 1 Col 2 Col 3 Tabela B Col 1 Col 2 Col 3 Tabela C Col 1 Col 2 Col 3 Tabela D Col 1 Col 2 Col 3 Relacionamentos: A (col 1)…
-
6
votes1
answer3395
viewsError creating table with INDEX VISIBLE in Workbench
I created a diagram of a BD using Mysql Workbench and had it generated. But the following error happens when I run the query: Executing SQL script in server ERROR: Error 1064: You have an error in…
-
6
votes1
answer141
viewsHow to determine a gap condition between records?
In the case of records containing date and/or time, how to determine that between the first record returned and the others there is always the same interval? Let’s take this example: Raw data:…
-
6
votes1
answer4362
viewsFree Mysql remote access 8
I’m testing the new version 8 of Mysql, and encountered some difficulty in releasing remote access (specifically, using the Workbench). What I found was same question on Soen, and only one…
-
6
votes2
answers48
viewsHow to create a View with 2 tables with different columns in SQL?
I have the following query: CREATE OR REPLACE FORCE VIEW "Resumo_vendas" ( "TIPO_REGISTRO" ,"VLR_DESCONTOS" ,"VLR_ACRESCIMOS" ,"VLR_PIS" ,"VLR_COFINS" ,"VLR_ICMS" ,"DTA_EMISSAO_NOTA" ) AS ( SELECT 1…
-
5
votes1
answer244
viewsHow can I detect and alert that a particular user is sending many messages in a row?
In a chat room, how can I detect and alert that a certain system user is sending many messages in a row (Flood)?
-
5
votes4
answers18077
viewsHow to organize auto-increment numbering of a column Id of a table in Mysql?
I would like after each insert or delete from my table to use an SQL script to rearrange the Ids. It’s kind of like this now: Id Nome 1 João 3 José 5 Ricardo I want to leave it like this: Id Nome 1…
-
5
votes1
answer114
viewsHow to select partially distinct lines?
I have a table whose column reference contains constructed values as follows:: Reference / Color / Size / Gender Examples: JOHN/WHITE/52/MALE JOHN/WHITE/51/FEMALE JOHN/BLACK/52/MALE…
-
5
votes4
answers4278
viewsMysql performance with Innodb in large data mass table
I currently have a table with about 6 million records that in turn perform a large amount of I/O operations, so in the design of the project I chose to use the Innodb instead of Myisam in Mysql,…
-
5
votes1
answer254
viewsWhat is a client-side Prepared statement?
I am starting to develop a page using PHP and, as I am still knowing the language, I decided to search which module to use to make the connection to a Mysql database. From of that answer, found that…
-
5
votes2
answers633
viewsMysql Query in PHP only works locally
The system I’m maintaining was using two types of query (don’t ask me why) and locally (localhost) works perfectly. When I uploaded the project to the server, the querys declared as such: <?php…
-
5
votes4
answers514
viewsError in mysql_fetch_object
I don’t know what happens in this mistake. Fatal error: Cannot use Object of type stdClass as array in $result = mysql_query("select * from usuarios"); while ($row = mysql_fetch_object($result)) {…
-
5
votes2
answers1352
viewsAlways presents an error when I try to use the mysqli expression
I know the expression mysql was discontinued, so I’m trying to use the expression mysqli, but every time I try to show myself on the screen a syntax error! example: $buscaDados =…
-
5
votes3
answers2432
viewsList months by year in mysql
Here’s what I’m trying to do php and mysql: What is in parentheses is the number of results within each month. For this, I am saving in my database, in the table tbl_noticias the field data of the…
-
5
votes2
answers178
viewsAbsolute ordering by data returned from DB
In PHP I am making a query to my database using Mysql. In my database I have the table fotos_album and inside I have the name of the photo. I want to sort the table by field nome. We imagine that…
-
5
votes1
answer7812
viewsSort table column datatable through query
I am trying to sort my table by the name field of my database table, but the jquery (datatable) plugin insists on sorting by id (first table field) How to force sorting through the query result, in…
-
5
votes4
answers5851
viewsHow to order a Mysql search with date in d-m-Y format?
The date on my bank is saved as follows dia-mês-ano. I would like to know how I can sort by date using this date format.
mysqlasked 10 years, 7 months ago Leandro Costa 2,172 -
5
votes2
answers18687
viewsHow to add values of a field grouped by date?
SELECT funcionario_id, data, avaliacao_postura FROM equipe id funcionario_id data avaliacao_postura 1 1 2014-03-02 -25;-10;-5;-12 2 1 2014-03-01 -25;-10;-18 3 1 2014-03-02 -25;-15;-14 I need to make…
-
5
votes3
answers2818
viewsCheck Mysql Connection Existence in PHP
I had this question recently, how to check if there is an open connection with mysql? Everyone knows that to use the mysql_real_escape_string need to have a connection right, so I wanted to check if…
-
5
votes1
answer125
viewsHow not to display past date records
I made a schedule and I need events that have already passed not appear anymore, dates are with 3 fields DAY/MONTH/YEAR, I am using the Concat and date to join and format the dates, so this is the…
-
5
votes1
answer822
viewsQuery slows down with ORDER BY
I have a problem, I have a query and when I use the ORDER BY she gets too slow. Note: I created an Index for the premium field and another for the score Follow the full query: SELECT p.id AS…
-
5
votes3
answers19465
viewsConvert string to MYSQL integer
What command can I use to convert string to integer in mysql? for example: I am making the following list of tables: SELECT mov . * , prod.produto, prod.unidade, prod.icms, prod.ipi, prod.codigo…
-
5
votes1
answer547
viewsIs it possible to create a foreign key from another database?
I want to reference a foreign key from a different bank, saw on some forums that it is only necessary to do `nome_database`.`nome_tabela`, but it’s not working. My code is this:: ALTER TABLE…
-
5
votes1
answer275
viewsMysql Transactions written in the same table
On seeing this answer I was left with this doubt: If we have 2 transactions to be treated at the same time, in the first (A) we are writing in table x, in the second (B) if we try to write in table…
-
5
votes3
answers394
viewsHow to fill an Object value automatically in php?
I need a method to auto-fill my VO by receiving as parameter a mysql database result set and php’s PDO class. Example of VO class Pessoa{ public $nome; public $idade; } The idea is to incorporate…
-
5
votes2
answers6602
viewsInsert data into database using mysqli
How do I insert this data into the database mysqli: print $data->access_token."<br />"; print $data->username."<br />"; print $data->full_name."<br />"; print…
-
5
votes2
answers1679
viewsSearch System - Select within another
Hi, I’m running a search engine, but I’m kind of a layman when it comes to querys. The method I thought to refine the search, which in this case would be a simple search between two fields of a…
-
5
votes2
answers6653
viewsMysql Commands out of Sync; you can’t run this command now
I have a class Import (PHP) which is used to read XML files and insert into the BD. First I got the class builder Import that creates a new connection mysqli: ... $this->mysqli = new mysqli(…
-
5
votes3
answers1785
viewsHow to deal with multiple queries?
I have a question related to good programming practices. How to deal with multiple queries on the same page in PHP. For example, the code: $qr = "SELECT historico.*, funcionarios.nome FROM historico…
-
5
votes2
answers456
viewsCreation of tables with Database scripts
In my application I have to create a table for each user, tables are created the first time when the user uploads a file and with the name table_$id_user. And the only way I see to create so…
-
5
votes1
answer10370
viewsSend email with Acentos BD Uft8
I’m having a problem emailing names from the database. Some names come with accents and when I receive the emails the names are disfigured. The database is as Utf8 - Default collation Php code:…
-
5
votes3
answers591
viewsSQL sorting only after the third character
I have a field in my table in Mysql that is string type, with the following data: Coluna 01DV 03DV 04DV If you enter the value 02CA the field lays like this Coluna 01DV 02CA 03DV 04DV I need him to…
-
5
votes2
answers201
viewsBetter/Secure way to transfer sensitive data to an android application through JSON
I am trying to develop an application for android that will work with a database in this case Mysql and I was thinking to make the communication between the database and the application through JSON…
-
5
votes1
answer354
viewsIs it possible to run a query (Insert) and only then check if it is duplicated?
I am reading an XML file and at the same time insert the entries in the BD. My code is like this: foreach($itens as $item) { ... if ( ! $stmt_insert_item->execute ( ) ) { if (…
-
5
votes3
answers339
viewsWhy is ':' used in queries?
I was looking at a php script and noticed that every time SQL query was written, this "operator". A part of the code $sql = "INSERT INTO categorias (nome) VALUES(:nome)"; $stmt = DB::prepare($sql);…