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
https://forums.phpfreaks.com/topic/123604-multiple-table-query/#findComment-638312
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
https://forums.phpfreaks.com/topic/123604-multiple-table-query/#findComment-638373
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
https://forums.phpfreaks.com/topic/123604-multiple-table-query/#findComment-638393
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.