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
-
247
votes6
answers12507
viewsWhy shouldn’t we use mysql_* functions?
A very common question is why should we stop using mysql_* functions? For example mysql_query(), or mysql_connect(). I see that many people use them, or stop using them but do not know the real…
-
199
votes9
answers12451
viewsHow to prevent SQL code injection into my PHP code?
I developed a PHP page for internal use of the company I work with and only very few people use it. Through this page it is possible to make some queries, insertions, changes and removals of data…
-
117
votes3
answers57155
viewsCharset iso-8859-1 and utf-8 compatibilization problems
The 1st Image I use the charset=iso-8859-1 In this 2nd image I use utf8 I have a news system where you can paste html or text from other pages. On the page where the news are presented I use the…
-
60
votes7
answers8794
viewsHow to Convert Mysql Database?
In the development of a web portal, using the git we made the control of everything that was changed at code level in the approval environment and with the Jenkins We moved the site to the…
-
47
votes1
answer5885
viewsHow to choose between Nosql and SQL?
Nosql databases are there, and one question I always have when starting a project is what criteria to choose between a relational database or not. How to evaluate my project to know the best option…
-
45
votes5
answers41645
viewsWhat are the advantages and disadvantages between Mysql and Postgresql?
I have been with this doubt for a long time, I see some people recommending the use of Postgresql, but it is not clear the advantages and disadvantages compared to Mysql. I want to define the bank…
-
40
votes5
answers10782
viewsWhat is a Mysql Transaction for?
I was studying some examples of Mysql with PHP and came across as following code snippet: try { $db->beginTransaction(); $db->query('query 1'); $db->query('query 2'); $db->query('query…
-
37
votes2
answers20576
viewsWhat are the differences between Myisam and Innodb?
What are the main differences between Engines MyISAM and InnoDB and what is the most appropriate situation for the use of each? I know that MyISAM can’t stand it FOREIGN KEY but supports FULLTEXT,…
-
36
votes8
answers7830
viewsIs giving a "SELECT" before an "INSERT" a safe way of not having duplicate records?
I have a table with a column codigo. I cannot set as primary key. In a system it receives many notifications before it checks with a SELECT to see if that code already exists in the table. If it…
-
33
votes5
answers74978
viewsHow to get the table name and attributes of a Mysql database?
How to get the names of all tables in the database Mysql? How to get the attributes (name, type, etc...) of a given table in the Mysql database?
-
32
votes5
answers41630
viewsMysql Limit Equivalent in SQL Server
Someone knows how to relate the differences between Mysql and SQL Server, including using LIMIT n,n? Or if you have a link that lists the differences would be nice. Example SELECT * FROM tabela…
-
31
votes5
answers12535
viewsWhy is Varchar(255) widely used?
Why in various databases, say to set the size as varchar(255)? For example, in a field email why put varchar(255)? It would not be better (in question of storage and processing speed) to put…
-
30
votes5
answers7016
viewsHow to delete all duplicates except one?
I have a table that has duplicate records. They shouldn’t be duplicated. Some records duplicated two, five and even thirty times by accident. I need to remove these duplicate records, but I need to…
-
30
votes3
answers5657
viewsWhat is the LOCK TABLES command for?
These days I came across a snippet of an SQL that had the command LOCK TABLES. I had never seen this before and, as little as I could see, it seems to me that this would be to lock the table during…
mysqlasked 6 years, 4 months ago Wallace Maxters 102,340 -
29
votes3
answers10218
viewsHow to create a real-time notification system similar to Stack Overflow?
I am developing a Help Desk system, and would like some ideas on how to create a notification system similar to Stack Overflow itself, whenever some new support is registered. I intend to use PHP,…
-
29
votes7
answers68940
viewsHow to make SELECT with ORDER BY and different criteria?
People can select with 2 "ORDER BY"? Table CATEGORY: If I make a SELECT like this: select id,nome from CATEGORIA ORDER BY nome ASC Mysql returns the names in alphabetical order, but I need it to…
mysqlasked 8 years, 6 months ago Hugo Borges 5,294 -
26
votes4
answers2688
viewsHow to package and distribute a web system?
I need a certain Web system - including the PHP server itself, as well as Mysql - to be "packaged" in an executable file, thus allowing the layman to use it in a kind of browser of his own. What…
-
26
votes2
answers119390
viewsHow to insert date and datetime into a table in Mysql?
The big problem is that after the insert, all values that have date, are as zeroes and in the format yyyy-dd-mm and not dd/mm/yyyy, as it was inserted initially. How can I insert these values into…
-
26
votes1
answer48265
viewsWhat character encoding (Collation) should I use in Mysql?
What is the most appropriate character encoding (Collation) for a Mysql database that will store Portuguese language data?
-
26
votes1
answer10816
viewsWhat is the difference between Mysql and phpMyAdmin?
What’s the difference between Mysql and phpMyAdmin?
-
24
votes3
answers36150
viewsHow to use Mysql on Android
After some searches, I saw that the only database that Android can use is Sqlite, It is correct this information? Because I have an application that connects to an online database (Mysql) and would…
-
24
votes4
answers4178
viewsWhat is the difference between joining tables by JOIN and WHERE?
What is the difference between joining tables by JOIN or by WHERE? Examples: SELECT * FROM clientes c JOIN enderecos e ON c.id = e.id_cliente; SELECT * FROM clientes c, enderecos e WHERE c.id =…
-
24
votes4
answers453
viewsTable change constraint with subquery
To documentation mysql says: you cannot Modify a table and select from the same table in a subquery you cannot change a table by selecting data from it in a subquery This applies to DELETE, UPDATE…
-
23
votes3
answers1636
viewsHow to create a conditional index in Mysql?
How to create an index filtered by a specific data range? As far as I know, it is impossible to do this directly in Mysql. In some other database systems, there is usually a WHERE clause for this…
-
23
votes1
answer2914
viewsIndexes in Mysql queries
Using indexes in mysql queries really makes the result come quickly for some large queries or tables. For example in the query below: SELECT * FROM table WHERE status = 1; For a table with 1 million…
-
22
votes3
answers12113
viewsCheck if a table exists in the database
How to check if a table exists in the database before trying to use it? <?php // define a tabela $table = 'banana'; // verificar se tabela "banana" existe aqui // $tableExists = ?? // executa…
-
22
votes1
answer9649
viewsWhich UTF-8 "collate" is the most suitable for Web (multi-language)
I usually use utf8_general_ci by default in my projects, but recently I found that other developers use utf8_unicode_ci utf8_general_ci: Unicode (multi-language), Case/Case Insensitive…
-
21
votes2
answers11055
viewsWhat is the advantage of using the ENUM type?
When I should use the guy ENUM because even today where I saw this guy being used he could be replaced by VARCHAR or even for a simple CHAR, I can’t see a case where in it it really becomes…
-
21
votes1
answer21108
viewsWhat is the purpose of the RESTRICT, CASCADE, SET NULL and NO ACTION options?
When creating a foreign key type relationship between two tables in Mysql, I can specify some additional options in the events ON UPDATE and ON DELETE that are associated with alteration and…
-
20
votes3
answers17226
viewsDifference in Index Unique and Unique Constraint usage in Mysql?
I would like to know the behavior/differences between a Indice Unique and Unique Constraints to the Mysql ? Many may think that it makes no difference in the database, but it does! And not only for…
-
20
votes2
answers11900
viewsHow to make a JOIN between two tables of two different databases?
I have the personal data (login, password, name, etc.) of the users on a different server than I will use in a new project. I would like to know how I can cross-reference information between two…
-
20
votes2
answers29759
viewsChange the "collation" and "Character set" of the database, tables and corresponding columns
Some older projects were designed for their immediate purpose and based on this, the databases, tables and columns were prepared in a way limited to the intended scenario. In order to update and…
-
20
votes3
answers4785
viewsPHP and Mysql, how are thousands of connections processed at the same time?
Using PHP and Mysql as an example, let’s assume that there are 1000 connections (clients) accessing the site and using functions that open connection to Mysql and make queries. How PHP and Mysql…
-
20
votes2
answers40655
viewsDifference between datetime x timestamp?
I am building a diagram in Mysql Workbench and I came up with this question, what is the difference between the two? I will work with this base in Java, java has problem with some of them?…
mysqlasked 9 years, 10 months ago LucasMotta 1,026 -
20
votes4
answers850
viewsReturn all equal items from different groups
------------------- - TABLE - ------------------- ID | GRUPO | OBJETO ---|-------|------- 1 | 1 | 1 2 | 1 | 2 | | 3 | 2 | 1 4 | 2 | 2 | | 5 | 3 | 1 6 | 3 | 2 7 | 3 | 3 | | 5 | 4 | 1 6 | 4 | 3 | | 7…
-
20
votes1
answer14650
viewsWhat are the differences between utf8 and utf8mb4?
When importing my mysql database to a windows server after having created it on a local server (xampp), I could not import into the server the script I exported from the database. So I decided to go…
-
19
votes4
answers35413
viewsHow to check events between 2 dates in Mysql?
Knowing I have a table called eventos, and this table has the columns id, titulo, inicio and fim. The columns inicio and fim are of the type timestamp, where the date and time of the start and end…
-
19
votes3
answers32219
viewsFetch last 7 days data from current date
I’m making a BD query, and I want to receive results from the last 7 days from the current date. For that, I have a field data of type DATA (yyyy-mm-dd) in table. I am doing the query in php, in…
-
19
votes3
answers1320
viewsWhat are braces {} in an SQL string for?
What are braces for {} in the following SQL string used in PHP for Mysql? $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$placeholders})"
-
19
votes2
answers594
viewsCollect Google Analytics data for Mysql tables
I have seen many examples of how to export data from Google Analytics to other formats as well as keep the exported data updated, but none so far served to export the data to Mysql given the…
-
19
votes1
answer10250
viewsWhat is REPLACE INTO for in MYSQL?
What is the purpose of the command REPLACE INTO in MYSQL? Example: REPLACE INTO tabela(col1, col2) values(value1, value2) WHERE id = 1
mysqlasked 8 years, 10 months ago Wallace Maxters 102,340 -
19
votes3
answers9682
viewsWhat’s the difference between Where and having?
Doing some tests on a database that in Mysql, I realized that: SELECT * From client WHERE uuid = '1kvsg4oracxq' returns the same result as: SELECT * From client HAVING uuid = '1kvsg4oracxq' What…
-
18
votes0
answers488
viewsRecursive call error in nested procedures
I have some procedures Mysql to do the following: The main code will always call the trial CALL sp_syncTabela. To sp_syncTabela will check if there is another specific process for the tableName…
-
17
votes2
answers3105
viewsWhat is the question mark in a query?
Use ? in a query really avoids the SQL Injection? Avoids 100%? I saw this code and I heard many people talking about it, saying it helps in this case and how to use it? Could someone give a better…
-
16
votes2
answers13578
viewsMysql error "expects Parameter 1 to be Resource, Boolean Given in"
$query = "Select * from servico where ID_SERVICO = $id"; $result = mysql_query($query); if($row = mysql_fetch_array($result)) { $nome = $row['NOME']; if($nome == 'Marketing') { include…
-
16
votes2
answers7274
viewsDifference in result between Mysql 5.5 and Mariadb 5.5
I have a query running on my site that is installed the Mysql 5.5.43, but when I went up on the server (which has the MariaDB 5.5.38 and I only came to know now) the query does not return the same…
-
16
votes4
answers3142
views -
16
votes3
answers44552
viewsHow to connect Python to Mysql database?
I wonder how I can make a simple connection to Mysql through a Python script. To do this I need to install some library? Or is there something that comes by default in Python (like in PHP)?…
-
16
votes4
answers4728
viewsHow to write values to the Mysql database using PHP?
I have a database that I created in MYSQL with the table called publicacoes. This table has the fields id, titulo, conteudo and data_publicacao. I would like to know how to insert values in this…
-
15
votes3
answers70810
viewsWhat are the appropriate data types for columns like address, email, phone and mobile phone for SQL database?
What kind of data are recommended to create the following fields: address, email, mobile number/phone?