Questions tagged as 'mysql'

2
answers

How to make a database connection using the Singleton project pattern

Well I do a lot of web applications, where all of them I use database, and every time I go to do a new project, I create a file responsible for doing the queries with the database (CRUD). I just want to change this, I want to make a file wher...
asked by 07.08.2014 / 17:41
3
answers

Comparison between PHP and mysql variables

I have no idea how to do a 'comparison' between 2 variables in the example below: ** if ($rows['block'] == $idBlock ) {/*....*/} else {/*....*/} So long as the id is equal to what is in mysql it will work, but it will have multiple ids sepa...
asked by 03.07.2018 / 20:50
2
answers

How to change the name of a column in a select in the database?

I'm doing a database for a college activity and was asked to show the table by changing the name of the attributes (columns) to " Nome do Cliente " and " Endereco do Cliente ". How can I do this? Example: Tabela: nome...
asked by 03.09.2017 / 20:52
2
answers

Error creating table: Invalid default value for

I was creating a table in the database and the following error appeared:    Invalid default value for "updated_at" Here's the table to create: CREATE TABLE 'user' ( 'id' INT( 11 ) NOT NULL , 'uuid' CHAR( 12 ) NOT NULL , 'fullname'...
asked by 05.04.2017 / 18:07
2
answers

Search script does not return results or errors

Well, I created a PHP search script, but it does not display results, and it also does not display errors. Fomulário <form class="navbar-form navbar-right" method="post" action="pesquisa_card.php"> <div class="form-group">...
asked by 07.08.2017 / 16:38
3
answers

How do I retrieve all data from the current month grouped by date?

I have the following table: +------------+--------------+-------------------+ | ID | vacina | data | +------------+--------------+-------------------+ | 1 | Cinomose |2017-07-10 10:11:15| +------------+-...
asked by 25.07.2017 / 14:56
2
answers

Sum in sql update

I'm running the following sql in my mysql: UPDATE 'cadastro' SET 'pontos'= 'pontos + 1' WHERE id = 102; I need to update the column table every time the column table is made that is of type int(11) When I run this sql it...
asked by 27.06.2017 / 21:27
2
answers

How to differentiate data from two tables with columns of equal names in a SQL request with JOIN?

I've combined two tables with JOIN , the two tables have some columns with the same names ... When extracting data with PHP how will I differentiate? Example : foreach($dados as $values){ echo $values['price'];...
asked by 07.12.2016 / 12:26
2
answers

A single SQL query for a user's products!

I have the following query: SELECT id_produto, produto, (SUM(credito) - SUM(debito)) as producao_total FROM produtos_farm PF INNER JOIN produtos P ON P.id = PF.id_produto WHERE PF.id_usuario = 20 AND PF.id_produto = 1 This returns me to...
asked by 12.01.2018 / 18:43
2
answers

How to add a foreign key to a table already created

I am a beginner in mysql and can not add a fk to a table I created. I have two tables (person, object) and I want to create a 'fk_person' in an object that receives the value of the 'id' attribute of the person. The tables are already configured...
asked by 29.01.2016 / 21:20