0

Normally if I want to get an instance from table I use the following script :

SELECT STD_NAME FROM STUDENT S1 ,STUDENT S2

suppose student as an inner query like :

SELECT  std_name  FROM student, grades where student.id=grade.std_id) as S1

how can I use this inner query to make 2 instances ,with less coding.

shall I do some thing like :

(SELECT std_name  FROM student where student.id>=10) as S1 ,S2

I am using sql server 2008

Edper
  • 9,144
  • 1
  • 27
  • 46
Margo Stefin
  • 31
  • 1
  • 8
  • 2
    Can you provide sample output? The question "how can I use this inner query to make 2 instances, with less coding" doesn't make sense (at least to me). – Gordon Linoff Nov 05 '13 at 02:20

2 Answers2

0

Why do you need to create 2 instances? They are equal.

But try:

( (Select x from A where A.x>=10) as S1) as S2
Iswanto San
  • 18,263
  • 13
  • 58
  • 79
Rui Martins
  • 3,337
  • 5
  • 35
  • 40
0

Use INNER JOIN instead of Table1, Table2 which could have unintended consequence, like

SELECT std_name, grades.grade 
FROM student 
INNER JOIN grades 
ON student.id=grades.std_id
WHERE student.id>=10

See examples for INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN

Community
  • 1
  • 1
Edper
  • 9,144
  • 1
  • 27
  • 46