my query is :
select * from category where parentid =6
this gives me all children of number 6, I wanted to select name of cat 6 as well.
Please help me out
small query problem
Moderator: General Moderators
Re: small query problem
Very difficult to understand what you want. No explanation, my best guess is the categories table is a recursive table within itself, the parent id links to other categories, and you would like to get the name of the parent category.
Selects everything from Category where parent id is 6, then joins the parent category on the id to get the name.
Code: Select all
SELECT c.*, p.name
FROM `category` c
LEFT JOIN `category` p ON p.id = c.parentid
WHERE `parentid` = 6- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
Re: small query problem
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
a last small question
i used
it returns me:
-24:00:00
I wanted to show it like
-24 Hours
if my input is
i wanted to show it
-24 Hours:30 Mins
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
a last small question
i used
Code: Select all
SELECT TIMEDIFF('2000:01:01 00:00:00', '2000:01:02 00:00:00')-24:00:00
I wanted to show it like
-24 Hours
if my input is
Code: Select all
SELECT TIMEDIFF( '2000:01:01 00:00:00', '2000:01:02 00:30:00' )-24 Hours:30 Mins
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: