FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Question about a mySQL statement





Talk2Tom11
I have 3 tables... student, guest, and registered....


student has an id number and there personal info.
Guest has an id number and there personal info.
Registered has a generated number which is it's key and then the student id and the guest id and then a date.

I want to display the lastname of the guests that are in the registered table that have been registered by a specific student.

For example... student with id number 1234. I want to get the last name of the people they have registered... the statement i used was...

Code:
SELECT g.lastname FROM guest g, registered r WHERE registered.stid =1234;


The problem with this code is that it just gives me the last name of all the guests in the guest table.

If someone could help me with this it would be greatly appreciated
Talk2Tom11
I found the problem.... I forgot to address a relationship between the guest id in the guest table and the guest id in the registered table. Thank you for anyone who was working on this problem.
Related topics
MySQL statement error (got me going)
was Hitler a Christian?
Inserting data to MYSQL with a PHP script
Indigoperl includes a copy of Apache 2.0.44, PHP 4.2.3, perl
Creating a Search Script with PHP for MySQL
Get error on ' and " when executing mysql statement
another question for all the PHP gods out there..........^^
finding highest entries - select and insert statements - eff
How do you handle double quotation marks?
htmlentities and htmlspecialchars
How do I make estra pages on my site? ex. something.com/more
What's more important, 2 understand something or believe it?
Why do people feel it's right to choose for others?
What Deems an Appropriate Reason to Lock Threads?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.