Subject: subquery
Posted By: khansa Post Date: 2/21/2006 1:19:09 AM
what is the syntax of writing subquery in my sql.

when i write this query
"select EmpID, EmpName from Employees where EmpID IN (select EmpID from rightlinks where RightID=3)"

it gives me the error

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select EmpID from rightlinks where RightID=3)' at line 1

khansa
Reply By: jmukesh Reply Date: 2/21/2006 1:49:50 AM
Check whether your version of mysql supports sub queries.
Subquery support was added in version 4.1.

If your version of mysql does'nt support subqueries.
then a workaround for your particular case..



Query 1 >> "select EmpID from rightlinks where RightID=3"
building up a string with your first Query like

11,12,13,14 which are EmpID seperated by comma and use the
generated string in the next query.

Query 2>>"select EmpID, EmpName from Employees where EmpID IN (11,12,13,14 )"

~Regards
jmukesh





Go to topic 40227

Return to index page 364
Return to index page 363
Return to index page 362
Return to index page 361
Return to index page 360
Return to index page 359
Return to index page 358
Return to index page 357
Return to index page 356
Return to index page 355