Questions tagged as 'sql'

3
answers

Difference in use Index Unique and Unique Constraint in MySQL?

I would like to know what behavior / differences between a Unique Index and Unique Constraints for MySQL ? Many should think that this does not make a difference in the database, but it does! And not only for the DBA / Administrator, but...
asked by 21.12.2013 / 12:48
4
answers

How to check events between 2 dates in MySQL?

Knowing that I have a table called eventos , and this table has the columns id , titulo , inicio and fim . The inicio and fim columns are of type timestamp , where the start and end date and time of...
asked by 04.02.2014 / 20:30
3
answers

How to generate numeric sequences in SQL without having to create tables?

Reading the question How to zero or null an SQL lookup for a date range for those whose value does not exist? I remembered a similar problem that I have. Usually when I need these sequences that relate to data range I use auxiliary tables to c...
asked by 25.09.2014 / 17:10
3
answers

Why "= NULL" does not work? [duplicate]

In%%, when fetching all records with a given field with value SQL Server , if I do the following no records are returned: SELECT * FROM clientes cli WHERE cli.cpf = NULL However, if you use the following syntax: SELECT * FROM...
asked by 17.05.2017 / 16:25
3
answers

What is ROW_NUMBER?

What is ROW_NUMBER used in sql server ? How and where should we use it? Do you have a simple use example?     
asked by 29.08.2017 / 18:53
3
answers

Search the data for the last 7 days from the current date

I am making a query to DB, and I want to receive results for the last 7 days from the current date. For this, I have a data field of type DATA (yyyy-mm-dd) in the table. I'm doing the query in php, mysql turn. $query = mysql_query(SELEC...
asked by 14.03.2014 / 12:59
3
answers

Not IN or Not EXISTS to use?

I have seen some answers here with Not In and some using Not Exists to answer the same question. I do not know the difference between both and would like to know about: Which of the two is best when considering performance?...
asked by 08.05.2015 / 16:08
2
answers

When to use SET and SELECT?

I know that as in practically all issues related to "one or the other" there should be situations where it is best to use SET or SELECT , in a procedure (for example). At work we have the habit of always using SELECT , ev...
asked by 29.09.2017 / 19:32
1
answer

How to use a specific index in a query in SQL Server?

I have a non-normalized table in SQL Server installed on my PC which is fed monthly by Integration Services (SSIS) from a report into an Excel worksheet. That is, I am keeping track of a certain report. This table has several key fields. Depe...
asked by 17.12.2013 / 13:24
2
answers

What is and what is the utility of the DUAL table for Oracle?

I came across this scenario while modifying a report in the system: One of querys is returning this table as DUAL : select * from dual But in the system there is no DUAL table, and the answer they gave me was that it was a native...
asked by 27.10.2017 / 19:08