Questions tagged as 'mysql'

2
answers

know the auto_increment of a MySQL table after deleting the last ID's?

Friends, I come to you to know who tells me how to know the auto_increment of a table. Suppose that id_campo has 30 values, but after 6 rows is deleted, it would be in id_campo (24) , but the auto_increment is at 31. Is there...
asked by 24.10.2017 / 21:00
2
answers

Problem with COUNT (*) Does not return data (PHP AND MYSQL) [closed]

I try to count the amount of invoices in the database: //conexion: $con=@mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if(!$con){ die("imposible conectarse: ".mysqli_error($con)); } if (@mysqli_connect_errno()) {...
asked by 27.04.2018 / 17:38
1
answer

Mysql get the next Monday at noon

Hello friends, could you help me with the following: I have a field with a timestamp format and I would like to know how to get the next Monday at midday to save it in date_end . journay date_start date_end 1 1515200400 1...
asked by 24.01.2018 / 02:57
3
answers

How to compare the field of a current record with the next, in order to know if it is repeated or not?

I have the following query: SELECT pa.codigo, @rownum:=@rownum+1 AS nro FROM presupuestosa pa , (SELECT @rownum:=0) r WHERE pa.obra=18 AND pa.empresa=1 ORDER BY codigo ASC I wish that for each repeated code field, I can save the value 1...
asked by 29.07.2018 / 23:22
2
answers

SQL statement to find a last record per customer by date

I am trying to create a statement that returns a field from a date, but under a certain condition. First of all I have a table with several fields, among which I am interested in the following image: What I need is for you to return...
asked by 05.03.2018 / 15:55
2
answers

After an UPDATE, I execute a select but the data is not updated

I'm working JPA, I run the following update: public int EditarUsuario(UserSys us) { EntityManager em = getEntityManager(); em.getTransaction().begin(); try { Query q = em.createNativeQuery("UPDATE 'user_sys' "...
asked by 25.04.2016 / 23:14
2
answers

How to avoid duplicate records in a mysql query

I have a table where I store companies. Then I have a table movements where I insert several effective amounts / bank and the id of a company from the company table. Structure of the company table: idCuCorriente | nBanco | ---+--...
asked by 06.12.2018 / 21:13
4
answers

Optimize a query with a repeated subquery of MySQL

I have the following query SELECT * FROM TABLA_A WHERE CAMPO_1 IN ( SELECT CAMPO_X FROM TABLA_B ) OR CAMPO_2 IN ( SELECT CAMPO_X FROM TABLA_B ) The query works, I hope you can optimize the call of in since they are equal. I have...
asked by 28.09.2016 / 00:39
3
answers

How can I know how many times a data is repeated in an sql query?

Good afternoon I want to know how to get the number of times that a type of data is repeated and take it to a table with php at the moment I have the following code but I do not know how to extract the number of times that a data is repeated in...
asked by 23.09.2016 / 22:35
2
answers

How to select records of the most recent date with MySQL?

I have table1 with the following records: campo1 campo2 campo3 Adrian 25 2016-09-17 Juan 27 2016-09-14 Alex 23 2016-09-03 Ana 31 2016-09-17 Rocio 29 2016-09-17 In the ev...
asked by 20.09.2016 / 03:38