Questions tagged as 'mysql'

2
answers

optimized form retrieve last mysql ID

What better way to retrieve the last id from the table? I tested these two methods and the orde by took longer, is there any more of these? Note: this will not be a query after insert. It will be a separate query. select max(campo_id) fr...
asked by 09.05.2016 / 02:22
2
answers

Make a conditional UPDATE on the ON DUPLICATE KEY

I have a query that receives data from a .csv and inserts the data into the table. If position is the same it updates the fields. I need to verify that position is different from 1 ( status ) in order to update. This...
asked by 19.11.2014 / 03:18
4
answers

SQL Query Joining 5 tables

I need help to make a query (multiple relationships) in my WebService + MySQL to return the result in my Android application. I have these tables: QueryIneedtoqueryaperson(tb_suspeito),withtheattributes(Name,cpfandRg).PreparedStatementstat...
asked by 30.10.2014 / 13:23
1
answer

COUNT and GROUP BY in two columns

Personal I am facing a question with a particular Query, I have already cataloged everywhere on the subject but without success. If there is another way to do what I'm trying, I'll thank you for the information So, I'll illustrate the scena...
asked by 19.11.2017 / 08:12
2
answers

Calculating average time

In my database I have a table that has the fields entrada , saida , the two fields have the format D-MM-YYYY H:M:S , I would like to do an average calculation. Ex: The average wait time is 30 min Based on all the results...
asked by 04.09.2017 / 14:52
1
answer

What does this piece of sql statement mean?

I have this statement in the database modeling file and would like to know what it is about. 'price_type' enum("S" "M")     
asked by 27.06.2016 / 12:38
1
answer

How do I change everything to a single php value

My question is this: In a table, I have a column named nomecliente . In this table I have several records, however the column nomecliente of the records are different from each other. How could I make a mysql_query UPDAT...
asked by 29.07.2016 / 21:34
1
answer

mysql Delete all records in a table except the first one

Can someone tell me where I'm going wrong? or is it possible to do this? I wrote the query like this: DELETE FROM reservas WHERE ID NOT IN (SELECT ID,IDORIGEM FROM reservas WHERE ID='387' and IDORIGEM='387'); The id field keeps always th...
asked by 30.06.2016 / 21:52
2
answers

View saved PDF file in a MySQL database

I have a field in a table where I place the PDF file. The type of this field is BLOB. I would like to know how to display this file on a PHP page, without having to create a directory. I just want the script to access the field of this tab...
asked by 30.01.2014 / 21:13
1
answer

Select data from two tables to display in a column?

Consider the tables for the customer registry: Person Table |ID|NOME|TIPO|EMAIL| Physical Table |ID|CPF| Legal person table |ID| CNPJ| inscricao_municipal| inscricao_estadual| My goal is to consult the data of all people,...
asked by 26.01.2016 / 19:20