Questions tagged as 'sql'

3
answers

_ (underline) in consultation with LIKE

I'm doing a query where I need to return all the information in a given table, which contains " _R _ " in the nomenclature. However, when using WHERE NM_CAMPAIGN LIKE '%_R_%' it returns me to other cases that only have " R _ ". How...
asked by 16.08.2017 / 14:55
1
answer

Error trying to convert Portuguese date into datetime

I have a problem and I can not find a solution to fix it. I have a date in this format: Wednesday, April 30, 2014 and I want to save this date in the database in type datetime . So I am trying to convert to type datetime , but I h...
asked by 30.04.2014 / 17:50
1
answer

Recommended way to populate variables with bank data

Assuming this dummy method to get data from the database, let's say SQL Server: public List<DadosDTO> ObterDados() { try { comand = connectionFactory.CreateCommand(); comand.CommandText = "SE...
asked by 01.08.2014 / 15:39
2
answers

What are the advantages and disadvantages of storing session variables in the database?

As of Rails 4.0, the ActiveRecord Session Store , which saved session variables in the database, was deleted by "performance issues." But the functionality continues to work through a gem . Today Rails uses the Cookie Session Store .    A...
asked by 03.11.2014 / 11:52
2
answers

How to check data range?

When requesting a vehicle reservation, the system enters the expected departure and return time code (we prefer to work with fixed codes instead of schedules to facilitate scheduling). What happens is that when the reservation is made at times a...
asked by 14.12.2015 / 13:09
3
answers

Change field type MySQL

I wonder if it is possible to change the data type of a column in Mysql. For example: I have a USUARIO table with the SITUACAO column, in varchar and need to change to bit . I thought about doing something like: UPDA...
asked by 08.10.2015 / 14:52
5
answers

What is the best practice to know if a row exists in a SELECT in MySQL?

For example, when we are going to check if a user is already registered in the table, we do not need any data return by the query, just check if the number of rows is greater than 0 ( num_rows > 0 ). In the scripts and frameworks...
asked by 09.07.2015 / 22:36
5
answers

In the ORDER BY of a SELECT exchange point by point

I have a table in MYSQL (you can see here link ), where the price is commas and not points: 2.33 11.00 When I will give an order by: ORDER BY preco ASC The system understands that it is a string and puts the 11.00 in front, how to do...
asked by 11.10.2016 / 21:14
2
answers

Query that returns if the child inherited the surname of the father and / or mother

I have a scenario that I need to sort my records where: Did the child inherit the surname of the father and / or his mother? Notice in the picture that if one of the child's last names exists in the parent's name the PAI? field ge...
asked by 19.04.2017 / 21:40
3
answers

How to get the value of a column corresponding to the maximum of another column?

I have a table with columns codigo , data and valor . I would like to get, for each code, the value corresponding to the most recent date. In what ways can this be done? And if there is more than one, which is the most efficie...
asked by 03.08.2014 / 19:57