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
-
4
votes2
answers4792
viewsCheck if it already exists in the table before entering record
I need to include a record in a table, however before inclusion to avoid duplicity it is necessary to do a check. As I have a column ID with as property AUTO INCREMENT, I can’t use the INSERT IGNORE…
-
4
votes2
answers128
viewsQuery conditional ordering in Mysql
I have a table called comentarios, formed by the columns: id, descricao, criado_em and comentario_pai, how it is possible to see in the photo. I need to create a query, in which the answers are…
-
4
votes1
answer46
viewsQUERY - Can anyone help me mount this query?
I have these 3 tables below: "users", "Friends" and "posts". I want to take all my friends who are in the table of Friends and display their posts, taking the name of each and their image (which are…
-
4
votes3
answers3810
viewsWhat is the difference between a View and a Stored Procedure in SQL?
I have come across SQL Views and also stored procedures. I would like to understand better, what is the difference between a view and a stored Procedure and what are its purposes? It would be…
-
4
votes1
answer370
viewsUse of CONCAT, CONCAT_WS and GROUP_CONCAT
I’m building a query where I look for results within the concatenation and get enough to ask for help. I currently use Mysql with the PHP application. In the example below, I look for the words…
-
4
votes1
answer1002
viewsSave Relationship 1:1 on Laravel 5.3
In my scenario, I have tables of users and teachers, where a teacher has a user, so I have a relationship 1:1. Migrations: create_users_table Schema::create('users', function (Blueprint $table) {…
-
4
votes2
answers58
viewsDifference between two dates with time greater than 24 hours?
I have the following query: Sqlfiddle Past 24 hours, it Zera the time and starts counting again. I need to draw the difference between the hours, as long as they have to pass 24 hours. For example,…
mysqlasked 6 years, 2 months ago Layla Comparin 553 -
4
votes3
answers89
viewsOFFSET next to COUNT(*) returns nothing?
When I make a query this way are returned me the data correctly(At the moment 2 lines): SELECT * FROM noticias ORDER BY data_noticia DESC LIMIT 30 OFFSET 2 But I need to know the number of lines…
-
4
votes1
answer134
viewsWhich correct way to add two fields
Good evening friends, what is the correct way to add up these two fields valuated and adherence and display the total value in the input. Membership = 3,500.33; Dependants = 90.33; Total Correct:…
-
4
votes2
answers1474
viewsIs it possible to do an INSERT and UPDATE in the same query in java?
I wonder if it is possible to make one INSERT and a UPDATE in the same query, that is, in the same operation. I’m using the following to do both operations. public Connection conn = null; ... conn =…
-
4
votes1
answer636
viewsChange cell color according to the result?
I am a beginner in this universe, and I am locked in my development into a simple function that I cannot understand. This code below gets a value from the database, and I would like in the color…
-
4
votes2
answers1241
viewsStore multiple select in a single column with PHP/javascript + Mysql
I’m having trouble storing multiple select in the same table field. In this case, when filling the form and marking more than one select, it stores only one and the input quantity field that is in…
-
4
votes3
answers296
viewsHow do prepare dynamic and generic with mysqli?
I have a mobile application that sends me the following parameters $tabela = $_POST[“tabela”]; // ex: “pessoa” $atributos = $_POST[“atributos”]; // ex: “codigo, nome, cpf” $valores =…
-
4
votes1
answer5022
viewsMysql command alter table, difference from "Modify" and "change"?
What are the main differences in change and Modify, in which cases should I use them ? alter table cadastro change nome nome varchar(20); alter table cadastro modify nome varchar(30);…
-
4
votes1
answer343
viewsGettype() Laravel
I’m trying to get the type of the columns of the tables of my BD, and how to use PHP with the Laravel I tried to use the GetType to pick up the guys and show on view. But the code is only returning…
-
4
votes2
answers558
viewsSort by the number of repetitions in a column?
In a query in Mysql I need to select the results and sort the results based on the amount they repeat using the column id_livro, for example: My table comments: +----------------+-------------+ |…
-
4
votes2
answers7919
viewsHow to join 2 select in mysql
I have 2 select which are basically identical, changing only 1 table. I’m trying to put the 2 together in a single select, but I’m not getting it. Follows the select: SELECT DISTINCT a.id,…
-
4
votes2
answers1028
viewsHow to perform an Insert or update of a JSON object
JSON object $postdata: { "0": { "codigo": "1", "descricao": "Bobina", "preco": "10.0000" }, "1": { "codigo": "2", "descricao": "Capa", "preco": "20.0000" } } Using Mysql, how to perform insert if…
-
4
votes1
answer2162
viewsSelect(combobox) Dynamic
I need to use one select dynamic on my page, in which when selecting the state(UF), it shows me in the next select only the cities of this UF. Likewise the neighborhoods. All this information is…
-
4
votes3
answers85
viewsHow do you adjust my query date?
$result_usuario = "SELECT * FROM vendas WHERE DATE(date_created) = '$data' AND tipo_venda = '$tipo_vendas' AND tipo = '$tipo_pagamento' ORDER BY 'id'"; I have this query, but it doesn’t work right…
-
4
votes1
answer203
viewsR connection to Myqsl
Does anyone know how #Mysql can have access to a dataframe that was handled in R, I have already connected to the following script install.packages("RMySQL") install.packages("RJDBC") library(DBI)…
-
4
votes2
answers602
viewsReturn Zero in Function Mysql if query is NULL
I have this function: BEGIN RETURN( SELECT valor_desconto AS desconto FROM ItemCardapio WHERE id_produto = idProduto AND id_cardapio = idCardapio ); END How do I return 0 if the consultation is…
mysqlasked 5 years, 9 months ago Rafael Silva 944 -
4
votes0
answers751
views#2002 - No such file or directory no phpmyadmin
I am using MAC OS Sierra (safari 10.0.3), MAMP 4.0.6, phpMyAdmin and netbeans. Everything was going very well, had already run the application some times until suddenly the computer stopped. I…
-
4
votes2
answers260
viewsHow do I edit a JSON within my database?
I have a JSON saved in my database. I would like to know how to edit this json using PHP and saving it again in the database. The json that would like to change the value is this…
-
4
votes1
answer335
viewsGoogle Chart’s Line with While
Good afternoon, I have the following appointment: SELECT DATE(o.data_fechamento) AS Data, u.nome AS Pessoa, COUNT(*) AS Total FROM ocorrencias AS o LEFT JOIN sistemas AS a ON a.sis_id = o.sistema…
-
4
votes3
answers315
viewsWould it be possible to list Enum from a table field through a query?
I wonder if there is any way to bring the values of the inserted in the ENUM of a table column through a query. For example, with this table: CREATE TABLE shirts ( name VARCHAR(40), size…
-
4
votes1
answer1572
viewsMysql - What data types should be in quotes?
I’m developing a script for backup/dump from my database via PHP, but when saving the file, I need to put, or not, quotes according to the type of the column. So far so good! But what types of data…
-
4
votes1
answer149
viewsCURDATE() with day and time
In Mysql I have a table with field type DATETIME, with this value: 2019-08-01 15:30:00 For control, today is day 01/08/2019 15:05:00 I want to do a query that only shows if the date in the database…
-
4
votes3
answers160
viewsSelect Where IN all records
Gentlemen , will searched for days the answers to this doubt that I think is silly , but I could not. I created a view that has Matricula | Name |Job |Shift | Centrocusto | Codtreina | Status I made…
-
4
votes2
answers87
viewsSelect only 24 records per day
I need help to elaborate a query that selects only 24 records per day. For example: Day 1: 100 records Day 2: 50 records Day 3: 34 records I want to take only 24 of each day: 1, 2 and 3...(in this…
mysqlasked 5 years, 2 months ago Charles Fay 1,197 -
4
votes2
answers240
viewsHow to count repeat emails in a Mysql table?
I have a table where some registrations were made using the same email. I would like to count these repeated emails, for this I am using this way: SELECT COUNT(DISTINCT email) AS Contar FROM…
-
4
votes1
answer1248
viewsUsing Mysql with R in the Rmysql package
I am new when the subject is Mysql and installed this program to use with R. I managed to install the Rmysql library, following tutorials I found on the Internet and in the course I am doing in…
-
4
votes1
answer137
viewsHow to make an appointment to get the dates according to the weekdays?
How to make a certain query in MYSQL by picking the dates according to the day of the week? For example: +-------+---------------------+ | id | created_at | +-------+---------------------+ | 49185 |…
mysqlasked 7 years, 5 months ago Wallace Maxters 102,340 -
4
votes1
answer67
viewsWhat is the difference between sanitizers and validators in PHP
What’s the difference between FILTER_VALIDATE And FILTER_SANITIZE, in PHP.
-
4
votes1
answer1010
viewsTrigger para update before Insert
My database has two tables, notification and attendance, as shown in the image. In the notification table the default value of the status is "open". I tried to make a Rigger that updates the default…
-
4
votes3
answers1298
viewsPerform table insertion with foreign key
include_once 'acesso_bd/conexao_bd.php'; class PropriedadeDAO { function inserirPropriedadeBD($propriedade) { $nome = $propriedade->getNome(); $endereco = $propriedade->getEndereco();…
-
4
votes1
answer97
viewsgroup by semester/year PHP
Hello, I have a table with date field, I want to group by semester/year, I did so. SELECT SUM(quantidade) quantidade, YEAR(DATA) ano FROM tbmanipulacao GROUP BY YEAR(DATA), MONTH(DATA) <=6,…
-
4
votes1
answer118
viewsNumber of Columns X performance in tables
I am working with Mysql 10.x in a table that already has 60 columns, but it turns and moves I need to include more columns, I usually dismember in several tables precisely to not create a very large…
-
4
votes2
answers6024
viewsInitialize apache and mysql in windows 7 32 Bits using Xampp
I would like to initialize Apache and Mysql from Xampp as soon as the system is initialized, I did some research and found this: Service installation: In C:/xampp/apache double-click…
-
4
votes3
answers640
viewsHow to resolve foreign key error 150 in Migration with Laravel?
I’m having trouble creating the foreign key in Migration. I am working with PHP, LARAVEL 5.3 and MYSQL. You’re making the following mistake: Below is my code: Table Migration categs class…
-
4
votes5
answers2275
viewsHow to reduce the search time in a table with more than 200,000 records?
I’m trying problems to list and search data table with more than 200 thousand records. I read in researches, that for the search system, the ideal would be to make indexes of type "fulltext" in the…
-
4
votes1
answer107
viewsHow to search data from a third table based on the associative table
To put it in context: I have a table called principal and another called school. There are schools that directors who are registered with the name of the school. In this case, these schools are…
-
4
votes1
answer1312
viewsSee The Employee Salary Amount on a Given Date
Does anyone know what a query would look like to see what a certain employee’s salary is at a certain date? The table of the salary adjustment history of each employee has the following fields:…
-
4
votes3
answers259
viewsFilter a select, without duplicate SQL queries being returned
The problem is to return a SELECT with only those schedules that are no longer accepted by the user. I’m trying to use the schedule table that has already been accepted, which has both the user ID…
-
4
votes1
answer1227
viewsHow to filter by state cities in Laravel?
I made a filter in the Laravel and it works perfectly but nevertheless brings all the cities. It does not bring the specific cities of that state. I do not know if it is this filter that has to pass…
-
4
votes2
answers671
viewsFaster delete + Insert or select + update
I am building an app that will receive data from various different ERP’s every day. But I have the following problem, the next day the ERP can send me the same data that had or did not changes +…
-
4
votes4
answers882
viewsUpdate the data in the database without changing the others that already exist - PDO
Hi, I’m trying to create a page to change the registration data with mysql database, but it should only update the data that are filled and not change the other data if it already exists in the…
-
4
votes1
answer90
views -
4
votes1
answer369
viewsHow do I relate tables with json returns to php?
Please help, I’m new to programming and I need to do a table relationship Mysql, with return in JSON, I tried the following code, but it is in error. I already searched a lot on Google and Youtube,…
-
4
votes1
answer2068
viewsCOUNT and GROUP BY in two columns
Personal I am facing a doubt with a particular query, I have searched everywhere on the subject but without success. If there’s any other way to do what I’m trying, I’d appreciate the information So…