Jump to content

Recommended Posts

Yep I know but the problem is I'm not sure of any other way around it query wise without doing 1 complete mysql_query to get the logged in user's id and user_type and then doing another complete mysql_query to get the extra user details based on the user_type and user_if retrieved from the first query.

 

Like you said I'm not sure it's possible to do what I'm after in 1 query  :shrug:

Hi

 

Just use the syntax in my first post on this thread.

 

SELECT *
FROM users
LEFT OUTER JOIN regular_user_details ON users.id = regular_user_details.userid
LEFT OUTER JOIN business_user_details ON users.id = business_user_details.userid 

 

All the best

 

Keith

Aha gotchya so it would only be the result that has empty/null fields not the database as obviously I would be doing this:-

 

SELECT users.id, users.user_type, regular_user_details.name, regular_user_details.surname, regular_user_details.address, regular_user_details.age, business_user_details.company, business_user_details.contact, business_user_details.fax

FROM users

LEFT OUTER JOIN regular_user_details ON users.id = regular_user_details.userid

LEFT OUTER JOIN business_user_details ON users.id = business_user_details.userid

 

WHERE users.username = 'blah' AND users.password = 'blah'

 

And then if I have any more user types I just join onto those tables too correct?

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.