Questions tagged as 'sql'

2
answers

Displaying the last 30 days of a query

I'm trying some alternatives to show only the records of the last 30 days, but I could not make it work, the query I have looks like this: SELECT comunidade.descricao AS nomeunidade ,comcargo.descricao AS nomecargo ,comcolaborador....
asked by 03.02.2017 / 18:31
2
answers

MySQL Auto increment number pair

I have a MySQL database with a id field that is AUTO_INCREMENT . You have some configuration problem in it because at the time of making the auto increment it is coming out exactly in this sequence: ID: 2 ID: 12 ID: 22 ID: 32 ID: 42...
asked by 10.02.2017 / 14:59
2
answers

What is the difference between an empty string and NULL in SQL?

What's the difference if you store a string as NULL or empty in SQL? How can these two behave when I make a SELECT , or INSERT with value '' in that column that is of type varchar ? If I leave the de...
asked by 13.01.2017 / 15:58
2
answers

Get AUTO_INCREMENT value from a table

I want to get the last record entered in a database table, that is, the value of AUTO_INCREMENT of the table, I tried using: SELECT MAX(id) as max FROM people It works, but if I do not have any records in the table it will return...
asked by 06.07.2016 / 19:10
5
answers

Show all days between two dates

I need to display all the dates that exist between two defined dates. I do not need the information of the difference between these dates, nor of data that is in the interval between them, but rather display the dates for each day of the inte...
asked by 22.07.2015 / 20:00
2
answers

View or temporary table?

Looking at a code problem I came across different approaches to similar problems, where one has a view for data access, and another uses a > temporary table . I've been searching and found this question that deals specifically with...
asked by 10.09.2018 / 18:41
2
answers

Replace letter by empty or blank, something like Replace ("letters", "")

There is a A1_ZTEL field in the database that is varchar(15) . This way, each user entered a record of all forms, with bar, dot, comma and letter. Now I need to mount a form and read this field from another table that is var...
asked by 11.04.2018 / 21:47
2
answers

What are the advantages and disadvantages of using explicit transaction

Besides security, what is the advantage of using explicit transaction? In what situations is it recommended?     
asked by 24.06.2014 / 15:41
1
answer

SQL query within another query

I'm performing an update on the database, but it needs to get the last ID that was written. Where does where I put another command in? In this way: $sql = mysqli_query($conexao, "UPDATE cadastro set...
asked by 01.10.2015 / 19:56
4
answers

How to do select in 3 tables?

I need to do SELECT on two tables with relationship n to n , so I will have to make use of the middle table too, but I do not know how to do this. I'm using PHP and SQLServer database.     
asked by 23.11.2015 / 17:07