0
SELECT (RETURN) N_Numbers_Of_Categories_Id From Categories_Table

How to ?

My Table : categories

Columns are

Id , int
name, varchar(255)
parent_id , int

Data is stored as

ID      Name       PARENT_ID
1       A          0
2       B          1
3       C          2
4       D          3
5       E          4

I want out put like

ID
------
1
2
3
4
5

HOW TO... Need Simple SQL Statement HERE!

RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
fahad
  • 1
  • If you post code, XML or data samples, **please** highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar to nicely format and syntax highlight it! – marc_s Jan 29 '11 at 08:09
  • 4
    What do you want to achieve, your question is not clear. – Sarfraz Jan 29 '11 at 08:11
  • 1
    Can you give another example of what the output should look like? I'm not clear on what you're trying to query from this table. Are you looking for something from all rows, or just one? – Jon Jan 29 '11 at 08:13

2 Answers2

0

This gives you N category IDs from the table, N being 5

SELECT ID
From Categories_Table
ORDER BY ID ASC
LIMIT 5;
RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
0

The question is not very clear. But since you have ID and ParentID you may be interested in the discussion from an other question here on Stackoverflow

Community
  • 1
  • 1
bw_üezi
  • 4,483
  • 4
  • 23
  • 41