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
answer51
viewsJoin or separate repeated columns in different tables
I created a table tbl_users. But I have Profissionais and Empresas many columns are the same. It would be interesting to use in the same table, or it is better to separate?…
-
2
votes1
answer656
viewsDoctrine 2 INNER JOIN with Subquery
I’m migrating my appointments to Doctrine using the Querybuilder. And I have a consultation with Inner Join with a subquery, would like to know how to do this using Doctrine. SELECT p.* FROM…
-
2
votes3
answers103
viewsI’m not able to log data into the database
I’m a beginner in java and I have the following problem. On the state registration screen, I have a country selectOneMenu, and two fields for name and acronym. When I go to save in the database I…
-
2
votes2
answers186
viewsHow to select single data from a Join conditional?
I have 2 database tables: Servers +----------+--------------+ | Field | Type | +----------+--------------+ | id | int(11) | | ip | varchar(255) | | votes | int(11) | | port | varchar(255) | | hash |…
-
2
votes1
answer452
viewsSQL, subquery if null
I’m doing a query, but I didn’t want it to return NULL. What I got is this: select ifnull(sum(job_withdraw_qty),0) as total, ( select IFNULL(sum(job_withdraw_qty),0) from job_positions where…
-
2
votes1
answer942
views -
2
votes1
answer577
viewsQuery mysql with subquery Join
I need to create a query that I can filter the sales that have issued notes, in my structure there are 2 tables: the sales table and the table nfe. Both are related by the field cod_venda. How can I…
-
2
votes2
answers1004
viewsGroup table data with two columns
Well, I am in a incognita that I would like to solve directly in the SQL query, see this supposed example: TIPO | DE | IDENTIFICADOR ------------------------- 001 | 23 | 9 001 | 44 | 9 001 | 23 | 8…
-
2
votes0
answers39
viewsCount records that precede the selected one in the sql server, mysql query
I have a question: How do I know how many records you have before a selected value. For example: Select * from cidades where nome= 'SAO PAULO' ORDER BY nome Assuming that the cities table has 500…
-
2
votes2
answers2740
viewsSelect the first and last day of the previous month
I have the following query: select ADDDATE(LAST_DAY(SUBDATE(CURDATE(), INTERVAL 1 MONTH)), 1) primeiro_dia, last_day(sysdate()) ultimo_dia That returns me the first and last day of the current month…
-
2
votes1
answer3011
viewsError Code: 1215. Cannot add Foreign key Constraint
Can anyone help me? I can’t create this foreign key. Just follow my code: CREATE DATABASE escola2; USE escola2; CREATE TABLE IF NOT EXISTS aluno ( matricula INT, nome VARCHAR(25), sobrenome…
-
2
votes1
answer38
viewsHow to return the expected result in this query?
Good afternoon, you guys. The case is as follows: I have a table with 2 blogs of category "auto" and part of the title "Hackers" so whatever my query, can not return more than two results combining…
-
2
votes1
answer103
viewsHow to make a Unique field for each Foreign key?
I am studying mysql and came across the following situation and would like to know if there is a solution structuring my tables to solve this. Assuming I have two tables; user (id, user, password)…
-
2
votes1
answer31
viewsSyntax error and I don’t know where
I want to create a discount Trigger for case the user select the form of payment 6 that is billet he has 15% discount on the amount q will be paid, then the Valorpagar q is where is the amount that…
mysqlasked 6 years, 5 months ago Nathan Silva 87 -
2
votes2
answers760
viewsHelp with mysql Kurdate()-1
I’m getting this mistake: #1064 - You have an error in your SQL syntax; I’ve tried so many ways, but there’s always this mistake. Here are two of my attempts: SELECT `category`. * , `event`. * FROM…
-
2
votes2
answers1443
viewsTo fill a Select dropdown based on the value of another select, the data comes from the same table in db
I have a database where information is stored from the year on. On the site I have 2 Selects, one for year and one for the files of that year, currently I do this with JS but I wanted to switch to…
-
2
votes1
answer78
viewsGet the largest elements of an SQL column
I have 3 tables and I have the following question to solve: "Get the "name" with higher "Perce" related to "num2". Enter "num2" through "Name2" -- A (name,Num2, local) insert into A values…
-
2
votes2
answers82
viewsJoin bringing wrong value
I have two tables Enterprise: id_empresa id_usuario vl_honorario dt_honorario id_honorario 86 1 200 2017-01-04 7 86 1 600 2016-12-01 6 86 1 500 2016-11-01 5 86 212 300 2016-12-01 5 Honorary:…
-
2
votes0
answers54
viewsDropdown dependent upon DIV loading
I have in the file Fields.php the code below, which selects the company and according to the request will load divs with specific fields for that request. On the first request, I have to load the…
-
2
votes3
answers253
viewsComparison between PHP and mysql variables
I don’t have much idea how to 'compare' between 2 variables in the example below:** if ($rows['block'] == $idBlock ) {/*....*/} else {/*....*/} Until well, because if the registered id is equal what…
-
2
votes4
answers19922
viewsLimit the number of SQL query lines
I have the following Query SELECT estado, num_ocorrencia FROM bra_ocorrencias WHERE nome like 'João' ORDER BY num_ocorrencia DESC It returns me all the states with the most relevant occurrences…
-
2
votes2
answers521
viewsCheck duplicate items and update a column in all but one
I have a table of products that bring information from an XML, and another table in the system that basically receives these products after approval (we have an interface to define what enters or…
-
2
votes2
answers221
viewsError in CRUD UPDATE command - java.sql.Sqlexception: No value specified for Parameter 8
I am building a Java system with connection to Mysql database, but I stopped at a certain point because I can’t locate the error. My update method happens an error in Junit, but I can’t figure out…
-
2
votes1
answer1437
viewsTransform result into array and take all values in "select"
I’m having a problem when creating a system, I need to make a select: $select = $mysqli->query("SELECT * FROM `guild` WHERE `user_id`='$userid'"); $row = $select->num_rows; $get =…
-
2
votes1
answer354
viewsHow to update the database with SELECT Sum
I need to do the update of a table summing two values (money + deposited), thus obtaining the total. This total I already have using the code Select SUM(dinheiro)+(depositado) total from usuarios…
-
2
votes1
answer143
viewsMake a SELECT multiple tables and save to a spreadsheet
I’m trying to make a SELECT with multiple tables, where I have a product with your information, and I have another table structure to be able to add an extra field and its information. What I tried…
-
2
votes1
answer400
viewsTransform Array and String
How to transform an array similar to this and Strings to write each line in the Mysql database. I will only need the data of each array ( date, site and Status ) print_r($arrayOut); Array ( [1]…
-
2
votes0
answers28
viewsSelect in two tables with clause WHERE?
I need to check if a particular e-mail exists in two tables, if it exists in one of the two tables the user will not be able to register, facilitating would be the code below, the column email is…
-
2
votes1
answer193
viewsConsult real-time database inserts
There is a table in Mysql that suffers many insertions. The application needs to show these changes to the customer. Currently the existing application query, every 10 seconds, the table and shows…
-
2
votes1
answer44
viewsWhat is the OPTION=3 parameter for in the Database connections?
A database connection is usually something like this Driver=MySQL ODBC 5.1 Driver;Server=XXX;Database=XXX;UID=XXX;PWD=XXX;OPTION=3; Most google searches suggest this OPTION=3. In the mysql manual…
-
2
votes3
answers17051
viewsChange a select based on the selection of another select (from data in BD)
I have the following problem: In a form, I need to select a MANUFACTURER, and according to this selection, it shows the PRODUCTS linked to that manufacturer only. I have the following table where I…
-
2
votes2
answers239
viewsCreation of tables with cardinality 1 : N
I have two tables, PRODUTOS and INSUMOS. To create a product I need several inputs, I would like to know how I should proceed with this relationship in Mysql. I must create a table called COMPOSICAO…
-
2
votes1
answer421
viewsSELECT Multiple Date Range in Mysql
Guys, I have a problem extracting dates on a range of trainings. What I need is the following if a training had its beginning on 01/01/2017 and its completion on 03/03/2017 raise should return in…
-
2
votes0
answers182
viewsEngine with lower RAM consumption than Innodb/Xtradb in Mariadb?
Innodb allows you to make several INSERT and also UPDATE without creating LOCKING, while in Myisam it is not possible to make several INSERT at the same time and to make matters worse Myisam does…
-
2
votes1
answer90
viewsWHERE WITH DATES
I have this SQL that create group with sales whenever I had two sales of the same customer in TYPE = 1 and another in TYPE = 2, both completed in the current month. Only now beyond that, what I need…
-
2
votes1
answer241
viewsRollback transaction does not work as expected
I’ve recently been implementing a sequence of requests in Visual Basics, and would like to give a rollback when any fail. So I did it this way: Public Class DAO Dim connection As New MysqlConnection…
-
2
votes2
answers311
viewsExtended PDO connection does not work
The netbeans IDE does not show any errors, but when I try to run it always gives error in the browser, does anyone know what is wrong? can tell me how to use connection with father class builder…
-
2
votes1
answer46
viewsHow to create records in the MYSQL table according to the value of the $nregistros PHP variable
I have a $nregistros variable that defines the value of records to be inserted in the table "Formularios". If $nregistros is equal to 4 for example, it should insert 4 rows as follows: formularios…
-
2
votes1
answer49
viewsRule for selecting records based on date and time
I am developing an online betting system and when selecting the games registered in the system I need to select only the games from the current day onwards, additionally I need to make sure not to…
-
2
votes2
answers107
viewsSQL query returning null value
BD simulation in SQL Fiddle: http://sqlfiddle.com/#! 9/3f62be/1 Javascript: // Auto-salvar $(function () { $.post("actions/autosalvar.php", function (data) { console.log(data);…
-
2
votes1
answer66
viewsSelect random ID between 2 and 4
It is possible to randomly select the ID by placing, for example, the ID numbers that can be drawn (2/4)? Note: Only one line of this selection should be returned. I put this code but it wasn’t:…
-
2
votes4
answers1358
viewsHow to return the date and time closest to that informed by the user
I have a table with a list of places a truck has passed with the date/time of its entry and exit +----+------------------+-----------+---------------+ | ID | DATA E HORA | LOCAL | ENTRADA/SAIDA |…
-
2
votes2
answers301
viewsDoubt to use Replace together with Inner Join
I’m using the Inner Join to combine two tables: SELECT eventos.colab_id, colaboradores.setor FROM colaboradores INNER JOIN eventos ON colaboradores.id = eventos.colab_id So far so good, however I…
-
2
votes2
answers50
viewsTravel consultation
I have a table that records steps of a drive. For example: Date - Movement - Product 2018-30-10 - produced - id1 2018-30-11 - packed - id1 2018-30-12- dispatched - id1 2018-30-10 - produced - id2…
mysqlasked 6 years ago Pedro Augusto 2,392 -
2
votes1
answer275
viewsHow to get total sales by months with mysql
I have a sales chart that records the date and time of sale. The output format is this: "2018-09-02 15:00:08" I wanted to get the total sales per month but I’m having difficulty to assemble the…
mysqlasked 6 years ago Daywison Ferreira Leal 167 -
2
votes1
answer742
viewsIf with two conditions
I need in a select to add a field, for this I need to check two conditions, if the currency is 3 divided by the exchange, if the operation is 18 take all the sum and multiply by -1. The select I…
-
2
votes1
answer1074
viewsDynamic form and send to mysql via jquery and ajax
Already open some questions about it , I was helped , but kind of the way they spoke only serves if the form is normal , with inputs with name"something here" my form only has an input"text"…
-
2
votes1
answer27
viewscompare dates within the sql query
I need to compare the date registered in the bank +10 days with the current date and display the student that the current date is greater than 10 days, but this within the sql query. Is there a…
-
2
votes1
answer49
viewserror with EF and Mysql query
I have the following consultation: var produto = (from a in context.ItensReceita join b in context.Receita on a.t0080_id_receita equals b.t0080_id_receita join c in context.Medicamento on…
-
2
votes1
answer810
viewsInsert Mysql data with file . txt
I have the following file, somewhat simple: new_user.txt JOAO|18|JOAO VITOR BARBOSA|MANDAQUI ROGERIO|38|ROGERIO JOSE DE BARROS|CAPAO REDONDO My table in the bank was created as follows: users create…