Jump to content

Query from 3 tables


web_master

Recommended Posts

Hi,

 

I got a problem, and I will try explain what I want on a simpliest way as I can.

 

So, I got 3 tables.

 

1. Group

2. "Under" group

3. Basic text

 

Well, the "Group" table cols is looks (simplified) like this:

ID

GroupName

 

The "UnderGroup" table cols is looks (simplified) like this:

ID

UnderGroupName

 

The "BasicText" table cols is looks (simplified) like this:

ID

Txt_Group_ID

Txt_UnderGroup_ID

Txt

 

I want to reload text to look like this:

 

I. GROUP NAME

- Undergroup

1. txt

2. txt

3. txt

...

 

II. GROUP NAME

- Undergroup

1. txt

2. txt

3. txt

...

 

Uh, I hope it is understable...

 

Thanx in advanced

 

T

 

Link to comment
Share on other sites

I try this... but its not good...

// Reload from dBase
$QueryReturn2 = mysql_query( 'SELECT
`refgroup`.`refgroup_id`,
`refgroup`.`refgroup_name_sr`,
`references`.`references_group`,
`references`.`references_id`,
`references`.`references_txt_sr`,
`refpodgroup`.`refpodgroup_id`,
`refpodgroup`.`refpodgroup_name_sr`,
`references`.`references_podgroup`
FROM
`references`
Inner Join refgroup ON refgroup.refgroup_id = `references`.references_group
Inner Join refpodgroup ON refpodgroup.refpodgroup_id = `references`.references_podgroup
GROUP BY `references`.`references_group`
ORDER BY `refgroup_id` ASC
');

// Check query
if(!$QueryReturn2) { echo mysql_error(); exit; }

// Request query
while($REQUEST = mysql_fetch_array ($QueryReturn2)) {
echo 'GRUPA ' . $REQUEST['refgroup_name_sr'] . '<br />';
echo '- ' . $REQUEST['refpodgroup_name_sr'] . '<br />';
echo $REQUEST['references_txt_sr'] . '<br />';
}

 

Its show me:

 

I GROUP (refgroup)

- Undergroup (refpodgroup)

1. Txt (references)

 

II GROUP (refgroup)

- Undergroup II (refpodgroup)

1. Txt (references)

 

There is a more than One "references" that belong to "refpodgroup" and "refgroup"

 

So I want to looks like this

 

I GROUP (refgroup)

- Undergroup (refpodgroup)

1. Txt (references)

2. Txt (references)

3. Txt (references) ...

 

II GROUP (refgroup)

- Undergroup II (refpodgroup)

1. Txt (references)

2. Txt (references)

3. Txt (references)...

Link to comment
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.