filter sql rows using update statement
I am trying to write a query which can get invalid refby(is related to
id), please check following db structure...
| id | acnumber | refby |
+----+-----------+--------+
| 1 | ac01 | 2 |
+----+-----------+--------+
| 2 | ac02 | 1 |
+----+-----------+--------+
| 3 | ac03 | 5 |
+----+-----------+--------+
As you can there is no id with value of 5 in above table so query must
return 3rd row as result.
I have tried...
SELECT * FROM tbl.members WHERE refby != (SELECT id FROM tbl.members WHERE
id = refby)
But not giving correct results, please help, thanks.
No comments:
Post a Comment