Questions tagged as 'sql'

1
answer

Interval in minutes of a period

I'm trying to make a select that lists in a range of 10 minutes a value of the bank, is there any way to show the data even though it does not have data in the range correctly? Example :    00:00:00 = 0      ...
asked by 21.11.2016 / 14:45
1
answer

Using Case When with LeftJoin

I am putting together a proc, but depending on the value of a parameter, I would like the left join to be different. I have tried the querys below: This works, however, else as null or even else , if the parameter COD_...
asked by 07.08.2016 / 22:45
1
answer

Tuples separated by commas

I'm doing a query in the database (mysql) where I have a code and through this code there are several types of people. I need when I make query come like this ID | NOMES 1 | Fulano 1, Fulano 2, Fulano 3 2 | Fulano 2, Fulano...
asked by 09.08.2016 / 20:46
1
answer

Replace in update, change the extension to file names

I have a table with images, images , in which one of these columns ( file_name ) has image names, jpg other png , what I need is to change, make UPDATE all to the extension png , that is, change any extensio...
asked by 21.10.2016 / 13:45
1
answer

Looking for nearby places with DISTINCT? (Maps API)

I have a separate table in MYSQL with the addresses of the users containing the location information (latitude and longitude), each user being able to have more than one registered address. My goal is that when performing a search for a location...
asked by 27.02.2017 / 03:12
2
answers

How to use the like in a field comparison in different tables?

How can I use LIKE for a comparison of two different table fields? I need to compare the first 5 characters of each field. I tried SUBSTRING and with LEFT , however, the performance gets pretty bad. Here are two ways I applied, with the c...
asked by 22.02.2017 / 13:40
1
answer

Remove old MySQL records automatically

I have a table that stores logs for a system. I want some method of automatically deleting records longer than 60 days. Can you do that?     
asked by 07.07.2016 / 21:32
3
answers

SQL - Return records to zero

Good morning, I have a query that is returning only the months with sales consumption, which should be the correct one. But now a blessed user wants me to come back every month, even those who have not had sales. How do I return as zero inclu...
asked by 27.06.2016 / 15:41
1
answer

Sorting multiple columns

The sales table has the following structure: id_venda | nome_cliente | data_venda | data_agendamento | data_cancelamento | data_ligacao Where the "date" fields are all datetime. I would like to sort according to the last move that occurred....
asked by 19.11.2018 / 20:32
1
answer

Bring results from two tables (INNER JOIN error)

I have the secretaries table with the following structure: Andtheworkertablewiththefollowingstructure: Ilinkedtheworkertabletothesecretariestablethroughthefollowingrelation: That is, I'm relating the Foreign key to the 'worker' table's pri...
asked by 25.06.2017 / 20:55