Jump to content

Compare two columns?


xeirus

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.