Click here to Skip to main content
15,909,953 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a table by name student, now I need to filter student table with columns id and name this will result into a another table namely s. In s table I need to get a result of s.id=dbo.toppers.id
(Select id,name from student)
 as s 
on s.id=dbo.toppers.id;


I am getting an error message "Incorrect syntax near the keyword 'AS'"
Posted
Updated 1-Jun-11 21:28pm
v2

You query definitely looks wrong. I'm not quite sure what you are trying to do. Are you selecting the name of a the student who's id = 5 in a table with alias s?

Then try
Select id.name from student as s where s.id = 5
 
Share this answer
 
Comments
Tarun.K.S 2-Jun-11 3:15am    
Oops you had already answered it! 5+
Abhinav S 2-Jun-11 3:20am    
No problem. :)
swathi6589 2-Jun-11 3:33am    
select id,name from student will result into a table namely x.I need to check the condition with table x
Tarun.K.S 2-Jun-11 4:10am    
Well you have updated your answer. Can you check mine if it worked for you?
try dis
if u want to get name means
select name as s from student where id=5 


else if u want id means
select id as s from student where id=5
 
Share this answer
 
v3
select s.id, s.name from student s where s.id="5";

Perhaps helpful for sql syntax:

http://www.w3schools.com/sql/sql_select.asp[^]
 
Share this answer
 
Hi Swathi,

Can you try this:
SQL
SELECT s.id, s.name FROM student AS s WHERE s.id="5"


UPDATE 2:

Then try this:

SQL
SELECT s.id, s.name 
FROM student AS s
JOIN toppers
ON s.id = dbo.toppers.id
 
Share this answer
 
v3
Comments
Tarun.K.S 2-Jun-11 3:22am    
Edit: Added s to id and name.
swathi6589 2-Jun-11 5:12am    
I think, I am not clear to u. By any query I will get a result in table form,can I use alias name for resulted table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900