I have some stored procedures in a SQL Server 2008 R2 database, these stored procedures have several joins , in some cases I used the < , inner join and left join , for example:
Tabela Pessoa
| IDPessoa | Nome |
| 1 | João |
|...
I have the following problem:
I have two tables. students and proof
Students have 10 students
evidence has 9 results (because one student was absent)
The union of the tables occurs through the enrollment field.
I want to merge the tw...
In my system, there is a system of postings and another system of friendships. Here is the structure of the tables:
posts : id | usuario | conteudo | data | hora
Friendships : id | usuario1 | usuario2 | status
And I'm us...
Considering the two forms of joining tables with a join (any):
SELECT Tabela.A, Tabela.B, Tabela2.C
FROM Tabela
LEFT JOIN Tabela2 ON Tabela.Id = Tabela2.TabelaId
And a union using from
SELECT Tabela.A, Tabela.B, Tabela2.C...
I have the following tables:
users :
id | usuario | pnome | snome | foto
1 | Igor | Igor | Souza | perfil.png
2 | Alex | Alex | Khal | foto.jpg
3 | Maria | Maria | Silva | foto.png
Friendships :
id | amigo1 | amigo2 | e...
Is there a difference if I use:
select *
from a left join b on a.id = b.id and b.id2=1
where ...
or
select *
from a left join b on a.id = b.id
where
b.id2=1
Sent on:
Fri
?
The first SQL returned me super fast, the second one did...
Why does a SELECT return a sequence number does not work if it has LEFT JOIN ?
SELECT @ROW_NUMBER:=@ROW_NUMBER+1 AS ROW_NUMBER,
P.PEDIDOID
FROM PEDIDO AS P,
(SELECT @ROW_NUMBER:=0) AS T
LEFT JOIN PEDIDOPRODUTO AS PP ON...