Tuesday, April 24, 2012

Suggest a MySQL Query

I have a table with 3 fields.



ID    Name     ParentID     Active
1 A 0 1
2 B 0 1
3 C 2 1


Now, I want a query where if there is row with ParentID > 0 and active then the row with its parent id (2) is skipped.



Please suggest a single MySQL query to achieve this.



Thank you,
Khuram





No comments:

Post a Comment