TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-16-2008, 02:10 AM   #1 (permalink)
The Wanderer
 
Join Date: Jan 2008
Posts: 13
Thanks: 0
Ultimatum is on a distinguished road
Default Get data from 4 different tables

Hi, I need a query that checks 4 different tables, to see if there is a match for the username/password filled in the form. 4 tables sounds kinda weird but it's pretty clear. I have 3 different people who can login. Students, companies and admins. Each has there own table with data, but company has 2 tables. 1 for companyname en 1 for departments.

But only the company table en department table are linked together. I have this at the moment but if there is a match from 1 table, I get data from all fields that are mentioned in the select. I hope that you understand, been strugeling with it for some hours now, so hope you can help.

This is the query I have at the moment:
Quote:
SELECT student_id, admin_id
FROM students, admin
WHERE (
(student_id = '8563' AND students.password= MD5('password'))
OR
(admin_id = '8563' AND admin.password= MD5('password'))
)
The output I get:
Quote:
student_id admin_id
8563 25
The combination for student was correct, but because I don't connect the 2 tables I get a result from the other table back aswell. But I don't want that result, only if the combination doesn't match in the table student but in the table admin. So it's impossible to see now in which table the match was.

Hope you still understand, my english sucks a little
Ultimatum is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:07 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design