Jump to content

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

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.