Jump to content

Inner Join


Darkness Soul

Recommended Posts

Hi guys,

When the user login, my auth-code save some information in a session, one of these information is the user flag.

I have 3 tables:
* user_data
* user_group
* user_flag

I verify the login/pass in [user_data], so, I start to record the session. I record:

* usr_name
* usr_id
* usr_group
* usr_flag

My problem is with the flag.. A flag just have a group_id with it. So, i was using a INNER JOIN to retrieve this flag_id, but not so happy, something was wrong.

My code:

[code]    $str_sql = '
SELECT
    user_flag.id AS id
FROM
(
    user_flag
    INNER JOIN
    (
        user_group
        INNER JOIN
            user_data
        ON
            user_group.id = user_data.id_group
    )
    ON
        user_flag.id_group = user_group.id
)
WHERE
    user_data.id = '. $int_id .'
LIMIT
    1
    ';[/code]
So, if someone know what I do wrong, I will be greatful, I'm new in mysql.. ^^"!

Bye.
Link to comment
Share on other sites

I've tried to built it on MS Access, and it give me this code, but still don't working..

[code]        $str_sql        = '
SELECT
    user_flag.id
FROM
(
    user_group
    INNER JOIN
        user_flag
    ON
        user_group.id = user_flag.idgrupo
)
INNER JOIN
    user_data
ON
(
    user_flag.id = user_data.id
)
AND
(
    user_group.id = user_data.id_grupo
)
WHERE
    user_data.id = '. $int_id .'
LIMIT
    1
        ';[/code]
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.