Questions tagged as 'sql'

1
answer

Remove "OR" condition from LINQ query

I have the following method: bool naoUsarNomeCliente = String.IsNullOrWhiteSpace(filtro.NomeCliente); long codigoExterno; bool naoUsarCodigoExterno = !long.TryParse(filtro.CodigoExterno, out codigoExterno); bool naoUsar...
asked by 09.06.2017 / 21:05
2
answers

Entity Framework or Stored Procedure

When to use Entity Framework example: var registros = db.Tabela.AsQueryable(); registros = registros.Where(r => (intTipo == 0 || r.IdTipo == intTipo) && r.IdArea == intIdArea && r.DataInicio <= DateTime.Now && (...
asked by 22.01.2015 / 15:22
4
answers

Change registration day only

Scenario (example): I have the following table: ID | TIPO | DATAINCLUSAO 1 | 10 | 21/07/2018 09:34:51 2 | 10 | 11/07/2018 11:15:25 3 | 11 | 23/07/2018 01:52:31 4 | 11 | 04/07/2018 23:24:52 5 | 12 | 25/07/2018 03:43:33...
asked by 15.08.2018 / 14:23
2
answers

How to change the name of a column in a select in the database?

I'm doing a database for a college activity and was asked to show the table by changing the name of the attributes (columns) to " Nome do Cliente " and " Endereco do Cliente ". How can I do this? Example: Tabela: nome...
asked by 03.09.2017 / 20:52
2
answers

How to differentiate data from two tables with columns of equal names in a SQL request with JOIN?

I've combined two tables with JOIN , the two tables have some columns with the same names ... When extracting data with PHP how will I differentiate? Example : foreach($dados as $values){ echo $values['price'];...
asked by 07.12.2016 / 12:26
4
answers

Creating base date using StringBuilder

I'm creating my database with class sqliteOpenHelper , passing DB creation by String through StringBuilder . The problem is that you are only creating the first table, and then you do not create the next table, in which case I...
asked by 10.11.2015 / 23:27
2
answers

Select with the day of the week in Portuguese

Good afternoon, I need to make a select that translates the day of the week into Portuguese, it's already working, but in English. How can I change? Select *,id, data, mes,date_format('data','%d/%m/%Y') as 'data_formatada' FROM (SELECT DAYNAME...
asked by 19.02.2016 / 16:25
4
answers

How to perform query with some null values?

The SQL below returns the values correctly only if the data_emissao field is as not null in my DB table (regardless of whether the cliente parameter was passed or not), however I want to return the values where the data...
asked by 28.02.2017 / 22:00
3
answers

How to do SELECT on more than one database table?

I have two tables in the database: zip and users. Can I make a single query to get fields from the two tables? Both have idCep. I want to get the address data from the cep table and the name and user of the users table. As I'm working with ph...
asked by 25.04.2016 / 20:31
2
answers

Set default SQL Server column value

I would like to know how to set an insert pattern in a column in SQL. Example: CREATE TABLE XPTO( ID INT IDENTITY(1,1), NOME VARCHAR(100) NOT NULL, ATIVO CHAR(1) NOT NULL) In this case, I want to limit the ACTIVE fie...
asked by 15.03.2017 / 17:14