Now i want to delete only one record of this, so i found LIMIT does not work with DELETE.
So i tried like this :
$query="DELETE FROM employees
WHERE empno
IN
(SELECT empno
FROM employees
WHERE empno='$empno'
AND dep_id='$dep_id'
AND sec_id='$sec_id'
AND pos_id='$pos_id'
LIMIT 1
) ";
[COLOR="#FF0000"]ERROR : You can't specify target table 'employees' for update in FROM clause[/COLOR]
$query="DELETE FROM employees
WHERE empno
IN (SELECT empno
FROM employees as [COLOR="#006400"]tbl[/COLOR]
WHERE empno='$empno'
AND dep_id='$dep_id'
AND sec_id='$sec_id'
AND pos_id='$pos_id'
LIMIT 1
)
";
Now it says “This version of MySQL doesn’t yet support 'LIMIT & IN/ALL/ANY/SOME subquery”
so this mean the query is working, but my wamp sql version out date i think …
oh madness,
i made a mistake in my post number 1, in that it is showing sec_id and pos_id are same for 3 records. but it’s not.
those columns values have diffrent values as showong below. also there is an auto increment column call ‘id’
sorry folks,
i think i totally messed up.
i really forgot that i have a unique ID column
after r937’s question only it came to my mind
problem solve when deleted using the combination of ID + Empno.