Users Pricing

forum

home / developersection / forums / mysql query suggestion

MySQL Query suggestion

Anonymous User 2295 02 May 2013
Hi All!

I have a MySQL table like this -

ID    NAME     PARENT
== ======== ===========
1     Class     0
2     Math     1
3     Physics   1
4     Cooking 0
5     Italian 4
6     Chinese   4

I want a query that will give me this output -

ID    NAME
== ===================
1      Class
2      Math Class
3      Physics Class
4      Cooking
5      Italian Cooking
6      Chinese Cooking

The parent's name will be appended with the child's name, like surname.

Please help me!
 Any succession will be appreciated! 

I am a content writter !


1 Answers