Questions tagged as 'query'

6
answers

How to SELECT all but a few fields?

It is well known ( and has already been asked ) you should avoid using SELECT * in some cases in queries to the bank. But imagine that I have a table with 50 columns, and I want to select 40 of them. Just selecting the fields would alr...
asked by 30.06.2014 / 15:58
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

Subqueries can decrease performance? Myth or truth?

Well, I usually only work with frameworks . I work with frameworks MVC and I usually use the ORMs to query the database. In my case I use Laravel, but I've used other frameworks , and had the recent opportunity to get to know the Entity F...
asked by 01.07.2016 / 21:37
4
answers

Performance of COUNT (*) and COUNT (1)

What is the difference between COUNT(1) and COUNT(*) in an SQL query. For example: SELECT COUNT(1) FROM USUARIOS; and SELECT COUNT(*) FROM USUARIOS; Is there any difference in interactions within SBGD? Which would...
asked by 20.06.2017 / 19:41
2
answers

SQL code optimization

How can I optimize the following code so I do not use 3 SELECTs and do not match the query to just 3 status ( SELECT * FROM historico WHERE his_status = 'FRACASSO' ORDER BY his_data DESC LIMIT 50 ) UNION ALL (...
asked by 11.11.2017 / 15:58
1
answer

What is Sargable argument?

In queries to the database what is the concept of a sargable argument (Search ARGument Able)?     
asked by 18.06.2014 / 17:52
2
answers

Error updating the entire JAVA table

I am trying to perform a mass update to update all the prices of products registered in the system, adding the value passed by the user to the unit price of the product registered, according to the company entered in the system and the product c...
asked by 18.02.2016 / 14:03
1
answer

Left Join or Not Exists

I needed to retrieve information that was in one table, but not in another. Searching found that NOT EXISTS would serve this purpose, but I saw that the Left Join has the same result: NOT EXISTS select pedido from logintegracao as A where...
asked by 09.12.2015 / 19:11
2
answers

Smart query with MySQL

I'm trying to make a more "smart" query in my DB, My question is how? I have a query : SELECT * from publicacao where titulo like '%$busca%'; and in my DB there are several publishing titles, for example: Farmácia Pharmácia Pharmacia...
asked by 22.11.2016 / 19:22
1
answer

Limit and Offset for web paging in SQL Server

I'm working with PHP and I have about 8000 records currently in DB. As it is for a web page, I need to make a pagination to be viable reading the data. As I understand it, I have to do something similar to limit and offset to...
asked by 28.11.2016 / 13:35