Questions tagged as 'mysql'

2
answers

Get only one repeated value in mysql

Well, I have a table and in it a field called cargo and its value can be repeated, for example, the position teacher. In my HTML I'm setting a <select> when I retrieve the value of this field, but due to the value of i...
asked by 12.01.2016 / 14:48
2
answers

Default registry if you have no other - mysql

Is it possible to program the database so that there is a default record if there is no other one in the table? making the table impossible to be empty. So if you have other records, it ignores the default, if you do not have any, use the def...
asked by 26.02.2016 / 15:00
1
answer

ENUM or Boolean?

I have a NOTICIA table and I have a column ATIVO News can be active or not if it is BOOLEAN (0 or 1) if it is ENUM . What would be best to use BOOLEAN or ENUM ?     
asked by 04.04.2018 / 22:36
2
answers

Create a record in which the user increments a new checkbox to save new information in MySQL

I need to create a customer registry, where certain part of the user's registration has several checkboxes that would use to store if the client has such documents, for example: [] RG [X] CPF [] Certidão de nascimento and a button so you c...
asked by 02.02.2016 / 04:23
2
answers

How to get the difference between dates and turn into hours?

In MYSQL, I know I can return a difference between dates using the DATE_DIFF function. example: SELECT * FROM table WHERE DATEDIFF(NOW(), created) <= ? However, I need to return the difference in day converted to hours in this...
asked by 16.06.2016 / 15:29
2
answers

How to create a MySQL database with SQL commands?

I would like to know how to create a database in MySQL using SQL commands, which I can run in MySQL Workbench, phpMyAdmin or any other software. What SQL commands do I need to create a database and its tables?     
asked by 17.05.2016 / 21:27
5
answers

How do I get the name and attributes of tables from a MySQL database?

How to get the names of all MySQL tables ? How to get the attributes (name, type, etc ...) of a given table in the MySQL database?     
asked by 11.12.2013 / 18:08
1
answer

WHERE with dates

I have this SQL to create group with sales whenever I had two sales of the same client in TYPE = 1 and another in TYPE = 2, both completed in the current month. But now, what I need is to filter sales with TYPE = 2 in the current month that t...
asked by 16.01.2017 / 21:19
2
answers

Formatting / masking CPF in MySQL or PDO

I have a "cpf" field in my table. This field can be of type INT or VARCHAR, in case I need to change it to solve my problem. In it there are only numerical values, without the dashes and without hyphen (.-). In PHP, when I'm going to call dat...
asked by 16.02.2016 / 22:58
2
answers

Syntax error in query

I'm running the following php code: require_once "config.php"; $pagina = $_POST['pagina']; $conteudo = $_POST['edit']; //mysql_query("DELETE FROM $pagina WHERE 1") or die("alguma coisa deu errado".mysql_error()); //mysql_query("INSERT INTO $pa...
asked by 04.03.2014 / 22:59