Jump to content

Select from 2 tables simultaneously?


jtakkinen_82

Recommended Posts

Hi, so now I have 2 tables, admin and users with the following fields:

 

Admin                 

-------

AdminID

name

password

email

level

 

Users

-------

ID

name

password

email

level

 

And what I'd need to do is search the both tables for the correct username and password on my login.php -page in one mysql_query. Is it possible? It doesn't need to detect if the logged user is admin or not, I'll do it differently. I'd only need to be able to check the both tables at the same time... it's a long story.

 

Link to comment
Share on other sites

My point is that your data is not normalised, you have the SAME information split over 2 tables. If "admin" status is merely a flag, then ALL admins are users (which means they can go in the user table) and ALL users can have an "admin" column to denote whether they are admin's or not. That way you can still apply a "level" to each user, and some are flagged as admins.

Seeing as they seem to share most of the same information anyway (email/username/password/id/level).

 

I'm sure fenway would probably concur. *looks for fenway's input*

Link to comment
Share on other sites

My point is that your data is not normalised, you have the SAME information split over 2 tables. If "admin" status is merely a flag, then ALL admins are users (which means they can go in the user table) and ALL users can have an "admin" column to denote whether they are admin's or not. That way you can still apply a "level" to each user, and some are flagged as admins.

Seeing as they seem to share most of the same information anyway (email/username/password/id/level).

 

I'm sure fenway would probably concur. *looks for fenway's input*

 

Yeah you're right and I think I got it sorted now that I no longer have to "tie" the users onto teams with "teamID". I'm using the intermediate table now so it should be all cool... your suggested way was the way I had done it originally but I didn't want admins to be in a team and that was causing problems...

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.