Jump to content

Query Help


btwong

Recommended Posts

People, i need help with a query. I could do this in 2 queries, but i don't want to do it, as it will be lazy, and has the potential to end up executing over 100 queries, when i could just do it in one...

 

anyway my table looks like this:

 

table1

id     name       link        parent_id
--------------------------------------------------------
1      link1       link.php     0
2      link2       link2.php    0
3      Sublink1    link3.php    1
4      sublink2    link4.php    1
5      sublink3    link5.php    2
etc

 

Know i want one query that will call all the links, but if it has a parent_id link of >1, add the parent links name (name) to come out in the query instead of the parent_id. So in essence the query will be calling itself.

 

am i to use a left outer join, or inner join or something else???

 

please help as i am frustrated as hell trying to work this out.

 

o yes, i am using this script on a PHP page with mysql.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/84865-query-help/
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.