Questions tagged as 'mysql'

1
answer

Invert value 0 or 1 in a column

I have a table that has many records and a column called posição . It only receives the value 0 for blocked and 1 for released. Now with a precise change, invert these values, where this has to be 1 and where this 1 has to be 0. H...
asked by 11.04.2015 / 01:14
2
answers

How to remove rows from a table A that has no relationship with table B?

I have 2 tables and want to remove rows from table A that have no relationship with table B? For example: In table B I have a field FK_ID and I want to remove from table A all rows that have no relationship with table B, ie, it does not have...
asked by 25.01.2017 / 18:46
1
answer

How to do JOIN in 4 tables or more?

I need to do a select in four tables but I'm having a headache with this, follow the image of how they're related: It would be something like: SELECT integrantes.id_integrante, integrantes_documento.nome_integrante, integra...
asked by 15.12.2017 / 14:30
1
answer

How to group COUNTs for different queries in one?

I need to do a SQL query to count indications, I have the following querys : SELECT 'FACEBOOK', COUNT(id) FROM 'clientes' where indicacao like '%face%' SELECT 'Instagram', COUNT(id) FROM 'clientes' where indicacao like '%insta%' SELECT 'go...
asked by 24.11.2017 / 15:41
1
answer

nodejs, get value from a mysql SELECT

Well, I wanted to know, how can I get this result, and turn it into variable and be able to use functions inside the script, example take that Name warrior and use it as a variable, type: con.query( 'SELECT * FROM servers WHERE id = ?'...
asked by 05.06.2017 / 11:17
2
answers

Calculate expiration date

I have a column named START in DATETIME format in MySQL and I would like to check if each row is expired and / or how many days are left to win that row, taking into account that the row expires in 30 days after the START date . I thought of...
asked by 08.09.2015 / 21:52
2
answers

PHP Mysql avoid registering in the bank in capital letters

Good morning, I have a database, where users enter various news. I have already talked to all of them, not to put capital letters in the inclusion, because it leaves the project aesthetically ugly. Is there a way to issue an alert when...
asked by 17.12.2015 / 04:03
2
answers

Count how many fields are blank in a MYSQL row

I have a registration table with 53 columns (address, phone, etc.). I wanted to set up a query that would bring me how many of these columns are empty or NULL, how can I do this?     
asked by 11.10.2018 / 19:49
1
answer

Randomized query in ascending order in MYSQL

I have a table where I have the student's name and punctuation, I need to pick up 5 random students and display them in ascending order of punctuation. I tried to do this, but he's just bringing students randomly and not ordering the score:...
asked by 27.01.2016 / 15:30
2
answers

Get current date in mysql

Colleagues. I have a table that stores the dates of the record with DATETIME (), but I need to check if the date of the record is equal to the current date, so I did it as follows, but it does not work: SELECT *,DATE_FORMAT(DataCadastro,'%Y...
asked by 01.02.2016 / 22:51