shan_cool Posted March 3, 2006 Share Posted March 3, 2006 Hi all, i hav an error in my subquerySELECT * FROM HR_Emp_Det WHERE Emp_LName=(select Emp_LName FROM `HR_Emp_Det` WHERE Emp_Id='368')it shows me,You have an error in your SQL syntax near 'select Emp_LName FROM `HR_Emp_Det` WHERE Emp_Id='368') LIMIT 0, 30' at line 1how to make it? am using mysql 3.23Rgds,Shan Link to comment https://forums.phpfreaks.com/topic/3985-pbm-wit-simple-sub-query/ Share on other sites More sharing options...
fenway Posted March 3, 2006 Share Posted March 3, 2006 No subqueries in 3.23 -- rewrite it as a JOIN (UNTESTED):[code]SELECT h1.* FROM HR_Emp_Det AS h1, HR_Emp_Det AS h2 WHERE h1.Emp_LName = h2.Emp_LName AND =h2.Emp_Id='368'[/code]I'm assuming here that you have an index on Emp_LName. BTW, I don't know where your LIMIT clause came from. Link to comment https://forums.phpfreaks.com/topic/3985-pbm-wit-simple-sub-query/#findComment-13968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.