2 Replies - 3072 Views - Last Post: 10 May 2012 - 05:23 AM

#1 big dream  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 10-April 12

"SQL command not properly ended"

Posted 16 April 2012 - 11:17 PM

hello everyone ,, I have problem when I run this command

select C.coursename, T.teacherid, T.teachername from teacher as T, course as C
group by C.coursename, T.teacherid, T.teachername;

error is appearing which is:
"SQL command not properly ended"


Could u please tell me what's a problem in it!!
Is This A Good Question/Topic? 0
  • +

Replies To: "SQL command not properly ended"

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: "SQL command not properly ended"

Posted 17 April 2012 - 04:43 AM

The "as" will probably throw it. Some databases do ";" at the end, some don't:
select C.coursename, T.teacherid, T.teachername 
	from teacher T, course C
	group by C.coursename, T.teacherid, T.teachername



However, the problem now is you can see there is no "where" clause. A new SQL engine might choke on that. The comma thing really isn't standard. Using join syntax will high light what you need to do:
SELECT c.coursename, t.teacherid, t.teachername 
	FROM teacher t
		INNER JOIN course c
			ON ???
	GROUP BY c.coursename, t.teacherid, t.teachername



Also, the group by makes no real sense. Perhaps:
SELECT c.coursename, t.teachername 
	FROM teacher t
		INNER JOIN course c
			ON t.teacherid=c.teacherid, 
	ORDER BY c.coursename



Hope this helps.
Was This Post Helpful? 1
  • +
  • -

#3 big dream  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 10-April 12

Re: "SQL command not properly ended"

Posted 10 May 2012 - 05:23 AM

Thanks a lot Baavgai..you were right
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1