Jump to content

Multiple Table Query


phpretard

Recommended Posts

You have to associate your where clause with the table so it would look more like this

 

SELECT table1.username, table2.username
         FROM table1, table2
         where table1.username = '".$_POST['username']."'
                  AND 
                  table2.username = '".$_POST['username']."'"

Link to comment
Share on other sites

So here is what I replaced it with and it tells give the error assign when a username does not exist.

 

$check = mysql_query("SELECT Administrators.username, Appraisers.username  FROM Administrators, Appraisers where Administrators.username = '".$_POST['username']."' OR  Appraisers.username = '".$_POST['username']."'")or die(mysql_error());

 

 

Any pointers?

Link to comment
Share on other sites

You see...

 

I have read through this BEFORE I POSTED and am not sure which applies to a login.

 

 

 

JOIN 
JOIN works in the same way as the SELECT statement above—it returns a result set with columns from different tables. The advantage of using an explicit JOIN over an implied one is greater control over your result set, and possibly improved performance when many tables are involved. 

There are several types of JOIN—LEFT, RIGHT, and FULL OUTER; INNER; and CROSS. The type you use is determined by the results you want to see. For example, using a LEFT OUTER JOIN will return all relevant rows from the first table listed, while potentially dropping rows from the second table listed if they don’t have information that correlates in the first table. 

This differs from an INNER JOIN or an implied JOIN. An INNER JOIN will only return rows for which there is data in both tables. 

Use the following JOIN statement for the first SELECT query above:
SELECT table1.column1, table2.column2 FROM table1 INNER JOIN table2
ON table1.column1 = table2.column1; 

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.