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
-
5
votes1
answer203
viewsWhat is the importance of specifying the size of a field in the field?
I would like to know if it really is, and why it is important to pre-specify the size of some string/text/... field in the Migrations in the Laravel. From what I imagine, maybe these specifications…
-
5
votes1
answer100
viewsAmount of index influence on performance?
I have a relatively large database. And the consultation in it varies a lot and I have some doubts regarding performance: 1- Create multiple indexes, taking into account the Where (E.condicao = '1')…
-
5
votes1
answer310
viewsHow to implement a pagination using PHP and Ajax
I make a query in the database through PHP that receives the data from an AJAX. (And then returns the query data to AJAX) So far so good. The problem is that I would like to paginate these data…
-
5
votes2
answers95
viewsSearch Duplicity in the table
I have a chart with 3 million phones, and I have the code for each customer. My goal is to find which phone repeats on different customers. For that, I can count how many times he repeats, but I…
mysqlasked 5 years, 1 month ago Gilson Andrade 61 -
5
votes2
answers2069
viewsDoctrine: Manytomany’s Relationship with Extra Fields
I have a many to many relationship between two tables: Products and Orders. The Doctrine then generates a third table. So far quiet. But wanted to generate in this third table more fields (Qtde and…
-
5
votes2
answers2279
viewsHow to get only the date month with PHP from the database
Well the date is in the format ( 2020-02-10 17:04:01 ) So I just want to take the month or day separately, the data is saved in the data Anco, I can get the whole date, but I wanted to take…
-
5
votes1
answer438
viewsHow to join 2 SQL queries into a single one (one is a mean value calculation and another search criteria with BETWEEN
I’m setting up a system that finds providers in a specific region, calculates the average value charged by them and brings this value. But before that he will only pick up the providers that are…
-
5
votes2
answers152
viewsHow to generate multiple columns in a query from just one column?
I need a Query that returns 2 columns summed (input and output) from the "accounting" column of the "tbl_sef" table. the value of the "accounting" column shall be in the column "input" when the…
mysqlasked 7 years, 3 months ago Jamerson Cavalcanti 53 -
5
votes1
answer482
viewsHow to select an option in select in a less laborious way?
I have a page called editarpublicacao.php who receives the id through GET. One of the two <select> for example contained on the page, is similar to that of companies: <select name="company"…
-
5
votes1
answer257
viewsWhat is more efficient, a complex query or treat the results?
I can do it: $sql = 'SELECT * FROM ' . 'data_companies ' . 'INNER JOIN data_companies_extra_infos ON' . 'data_companies.cod = data_companies_extra_infos.relationship'; $rs =…
-
5
votes1
answer137
viewsConvert SQL query to LINQ
How would this SQL query convert to LINQ: "SELECT SUM(valor_negocio) valor_negocio, " + " MONTHNAME(STR_TO_DATE(MONTH(data_inicio), '%m')) mes," + " STATUS" + " FROM negocio" + " WHERE data_inicio…
-
5
votes1
answer3432
viewsIs there any risk in using "SET FOREIGN_KEY_CHECKS = 0"?
According to what I read somewhere, the FOREIGN_KEY_CHECKS: ... specifies whether or not to check foreign key restrictions for Innodb tables. I mean, if the guy wants to disable the foreign key…
-
5
votes2
answers1104
viewsProblem with group by
I have the following query: SELECT funcionario.*, emprego.data_admissao, emprego.data_saida, emprego.data_dispensa FROM funcionario,emprego,empresa WHERE empresa.id = emprego.id_empresa AND…
-
5
votes0
answers419
viewsMonthly hours per shift
I have to create a php button so when clicking generate a monthly turn time, but I don’t see how to do it. Can anyone suggest an idea? What I’m thinking of is randomly choosing the contributions I…
-
5
votes2
answers462
viewsLaravel multitenancy with a user-only BD
I’ve been researching about Saas and Multi-tenancy but has little material in Portuguese. I saw that it is possible to make a database for each company, but my question is: You can make a unique web…
-
5
votes4
answers1156
viewsLogin condition with user or email in the same field
I am creating a system for schools, where the teacher when registering enters data such as name, email, user and password. So far the teacher can log in with email, but I wish you could login with…
-
5
votes2
answers947
viewsCounting weeks between two dates
I am trying to perform a query between two dates that returns the number of the week and counts progressively the week. As an example : Stayed like this : SELECT…
mysqlasked 6 years, 6 months ago Carlos Lopes 185 -
5
votes4
answers11349
viewsWhat is the difference between SMALLINT(3) and INT(3)
I have a question about the difference between two types of data in Mysql: That document has this table: The standard construction of these types is SMALLINT(M) and INT(M) where M = numero máximo de…
-
5
votes1
answer322
viewsConcatenate columns into rows
I’m trying to take several columns and turn them into a single row, but without success. That’s the select I’m trying to make: SELECT (`dias2produto`+`dias4produto`) as 'Até 4 dias',…
-
5
votes2
answers1079
viewsHow to do a random query in Mysql without repeating data?
I’m creating a site type images type Pinterest that, in addition to other things, need to combine the following features: Infinite Scrool (I’m applying this code here:…
-
5
votes1
answer3138
viewsWhy when using ON DUPLICATE KEY UPDATE or REPLACE, do we have change in 2 lines?
Example When executing any of the 2 commands, the message is returned: 2 Row(s) affected Query: ON DUPLICATE KEY UPDATE: INSERT INTO `banco`.`tabela` (`id`, `resumo`, `descricao`, `grupo`,…
-
5
votes2
answers255
viewsReturn the highest value between columns and the row ID of that highest value
Let’s say I have two columns in my table, column A and B. +-----+-----+-----+ | ID | A | B | +-----+-----+-----+ | 1 | 500 | 681 | +-----+-----+-----+ | 2 | 980 | 101 | +-----+-----+-----+ | 3 | 110…
-
5
votes3
answers141
viewsResult range
I have a table where records are saved every 3 seconds 24 hours a day Table: myTable dado1 dado2 dado3 data "135,05" "134,69" "135,10" "2018-11-13 15:38:16" "132,00" "131,91" "132,61" "2018-11-13…
-
5
votes1
answer4672
viewsHow to use SQL "LIKE" in Sequelize?
I am developing using sequelize but as it is my first time using this ORM I am with some doubts. I have the code below to make a query in the database through an input type text but I am using the…
-
5
votes1
answer189
viewsMysql returning all integers as string in PHP
Whenever I am making a query, PHP is bringing the data from the MYSQL database as string, and this is affecting data conversion when I send the customer a JSON response. For example, in the table…
-
5
votes2
answers2215
viewsWhat is the difference between using a "Constraint" in "Foreign key" or not?
When creating a table in Mysql I used to create fields CONSTRAINT FOREIGN KEY how are you following to create the foreign key: CREATE TABLE socio ( id_socio INTEGER NOT NULL, nome VARCHAR(256) NOT…
-
5
votes2
answers1140
viewsHow to make an Insert with columns and values coming from a select?
Imagine the following situation: Run a query in a database to acquire a particular record line, and then enter it again in the same table at the end of the records. It is possible that I can enter…
-
5
votes1
answer211
viewsMysql use 'as' in aliases or not?
Writing a query in Mysql I came across this doubt, I made a search, however, I found nothing (or did not know how to look for), the doubt is simple, there is some difference between using or not the…
-
5
votes1
answer325
viewsLogin with verification of two tables
Good afternoon, I’m developing a site, and I’m having a lot of doubts lately, it’s for my tcc and they help little. I made a system to register the user being a student or teacher with Mysql, in…
-
4
votes4
answers5177
viewsHow to handle vectors in a Mysql database?
I have a supermarket box application in which after the end of the sale need to insert a record with data related to this sale in a table, in this record must be included the code of the products…
-
4
votes2
answers4076
viewsView saved PDF file in a Mysql database
I have a field in a table where I place the PDF file. The type of this field is BLOB. I wanted to know how to display this file on a PHP page, without having to create a directory. I just want the…
-
4
votes3
answers1778
viewsHow to select rows from table A that are referenced in a column of table B?
I am trying to execute a database query to collect all rows in table A referenced in a column of table B: Query I am running -- Consulta a recolher da tabela A as linhas com ID referenciado na…
-
4
votes1
answer58
viewsHow to update the value of a column by substituting in all rows of the table?
I have a table i18n in the database whose column constant contains all values with prefix lang: Description of the table…
-
4
votes3
answers3146
viewsError when performing a database query
I’m using Zend and have the following function: public function getChamado($id) { try { $cols = array( 'id', 'titulo', 'descricao', 'fk_status', 'fk_local', 'fk_tipo', 'created', 'modified',…
-
4
votes2
answers1593
viewsChecking empty column with CASE in Mysql
I’m having a hard time making a query in a customer table. I need to find two columns (nomeCli and nomeFantasiaCli) and turn them into one: Nome. In short, when the client’s name is not filled in…
-
4
votes1
answer92
viewsError in db:create on Mac OSX Montain Lion
alexandesigner$ rails server dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info Referenced from:…
-
4
votes2
answers1219
viewsHow to insert Javascript code into the database?
I’m creating a function bbcode for a blog I am doing and wanted to know if it is possible (and safe) I insert Javascript codes inside my database. I am working with Mysql. Another question, I cannot…
-
4
votes2
answers1688
views1005 - Can’t create table '' Rrno: 150
I’m starting my programming journey and came across a mistake in the creation of the Mysql database: 1005 - Can’t create table 'mydb.supplier' (Rrno: 150) What could it be? I’ve entered several…
-
4
votes5
answers620
viewsHow to select records that have a relationship with all values in a list?
I have the following sql: SELECT DISTINCT cp_pessoa.id, cp_pessoa.nome FROM cp_pessoa LEFT JOIN cp_habilidade_freelancer ON (cp_habilidade_freelancer.id_freelancer = cp_pessoa.id) LEFT JOIN…
-
4
votes4
answers1407
viewsPrioritize word in SQL query - Mssql
I have the following task: Make a query where I have to give preference to the word passed as parameter. I search two fields with one OR, but I need to prioritize the consultation by the first…
-
4
votes2
answers6308
viewsOptimize Mysql tables
I work with some huge tables in a system I developed. These tables are constantly being updated and sometimes the query becomes slow. Some of them even have more than 100,000 lines. I would like to…
-
4
votes1
answer1853
viewsHow to import/export categories in Magento?
I am trying to import products and categories from one store to another, but in Malta there is only the option to export only products and customers. Is there any way to do that?
-
4
votes3
answers210
viewstimestamp does not indicate the correct date
I’m working on a CMS for display of the articles, my problem is with the function strtotime() does not indicate the correct date, always indicates 1 March 1970. The Row (phpMyAdmin) of one of…
-
4
votes3
answers16948
viewsMysql SELECT searching for value in another table
I have 2 tables: paginas and paginas_categorias On the table paginas I have a column called id_categoria, which would be the corresponding id of the table paginas_categorias. Using this id, I wanted…
mysqlasked 10 years, 8 months ago Gustavo Piucco 2,401 -
4
votes1
answer1449
viewsError inserting into Hibernate database
How do I insert the Product object into the database that is composed of an Ingredient object that already exists in the database, without duplicating the Ingredient object in the database. If I…
-
4
votes2
answers263
viewsLooping an array to always choose the next value
I have an array of users and need to make a looping between them. It will work like this, every time someone makes a request on the page, I need to be recorded in the database the next user of what…
-
4
votes3
answers7029
viewsInsert PHP into div with Jquery (.html)
I have a div that will receive the content, I have a vertical menu, which will define the content that the guy will see. The problem is that it does the .load() of the file, but it loads as far as…
-
4
votes3
answers15493
viewsHow to add the results of an array brought from the PHP database?
I’m doing this, but what’s being added up is the number of lines and not the field values "something". <?php $searc= mysql_query ("SELECT algo FROM lugar") or die (mysql_error()); while ($rows =…
-
4
votes1
answer391
viewsWhat is the weight of a subquery for the query?
During the development of some queries in the database, I come across the situation of the need to perform a new query, but another solution in some cases may be the subquery. So what is the best…
-
4
votes1
answer235
viewsGrab the latest message from a conversation (GROUP BY)
I have the following query: SELECT cp_mensagem.mensagem, cp_mensagem.dh_envio, cp_projeto.id as id_projeto, cp_projeto.nome as nome_projeto, cp_pessoa.id as id_freelancer, cp_pessoa.nome as…