Jump to content

Recommended Posts

Hi!

I have a table called "Categories"

 

Here is the structure:

id | Categories              |  ParentCategories

1  | Rings                        | Parent Category

2  | Pendants                  | Parent Category

3  | Ladies Rings            | Rings

4  | Ladies Pendants      | Rings

5  | Gents Rings              | Gents

6  | Necklaces                | Parent Category

 

But Necklaces is one of those who is not going to have any subcategories or you can say, it is going to be a category by itself.

 

So how can I construct a php statement to get data out of MySQL to determine that Necklaces is a Category which does not have subcategories.

 

Please help !

 

Thank you !

 

- Xeirus.

Link to comment
https://forums.phpfreaks.com/topic/237789-compare-two-columns/
Share on other sites

You can use a query to select all categories whose parent categories is equal to Necklaces. If there are 0 rows returned (which their should be) Then that means that Necklaces is a category without any sub categories.

 

Thanks milesta707 but ...

in this case I will have to embed Necklaces in my code which won't help the client as the client will be adding more and more such categories from time to time. So with your solution, I would have to hard-code the category name each time, which would bring me back to square-1.

Hope I'm making sense...

 

- Xeirus.

Link to comment
https://forums.phpfreaks.com/topic/237789-compare-two-columns/#findComment-1221935
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.