Questions tagged as 'sql'

3
answers

Can a primary key be used on a foreign key?

Can the following example occur? | Id | nome | data | qnt | PK -> Id FK -> (Id, qnt) Or are there any restrictions?     
asked by 16.10.2014 / 02:29
2
answers

Generic Repository with SQL

Seeing this question: Here I was wondering if it's possible / right to use an equal scheme in a project where I do not use some framework for connecting to a bank. I would like an example of the correct way to have a DAL layer, in which...
asked by 21.09.2014 / 17:27
2
answers

Duplicate keys

** Improving the Post for a better understanding of what happened. Person, good afternoon. I created a 'customer' table in the sql server and put the email field as vachar (50), unique and accept null Why logic, there are not 2 emails equa...
asked by 08.09.2018 / 19:55
3
answers

MAX () returning multiple rows

When I run the script it does not return only the maximum value, ie the longest time, but the 3 times. SELECT P.CD_PACIENTE CD_PACIENTE ,P.NM_PACIENTE NM_PACIENTE ,L.CD_UNID_INT CD_UNID_INT ,L.DS_ENFERMARIA...
asked by 21.09.2018 / 21:49
2
answers

INSERT INTO with filter in MySQL

I'm trying to create an INSERT INTO in an X table by making a filter in the Y table, but I get a syntax error. I researched what may be wrong, but not find out. INSERT INTO products ( SELECT * FROM products AS P WHERE P.FK_ID_QUOTE = 1...
asked by 27.11.2018 / 14:03
3
answers

Do not fill new column as Null and yes with specific value in the script

I have a specific table in the database, in it I keep information of classes that are created, swimming classes, futsal classes, bodybuilding classes and so on, it is already in use and with several classes already registered, but now I need the...
asked by 27.11.2018 / 18:45
2
answers

QUERY no expected result, what can be missing?

Complementing with current information, I understood the current result, and what it looks like is duplicate information, but on different tables, but this is not even with me since I arrived and it was like this and I'm still an intern, I'm jus...
asked by 07.04.2014 / 18:09
5
answers

Doubt in SQL query "between" or "in"

I am generating a report between date, as shown below: However,whenIenterthestartdate:Startingyear:2014Startmonth:6andFinalYear:2015FinalMonth:5IfIusetheINclausethequeryreturnsonlymonths6and5andnotreturningmonth4,butwhenusedBETWEENdoesnotretu...
asked by 18.06.2015 / 14:54
1
answer

How to close all active connections?

I have 8 connections open in the database and would like to close all of them, is it possible? What is the MySQL command that does this?     
asked by 04.09.2015 / 22:04
2
answers

Format output from select

I have a problem with formatting a column in gridview, this column receives three values from the concatenated database, the utlimo value can be null, if the value is null it does not have the last trace that separates the value 2 from the value...
asked by 03.09.2015 / 15:28