[thelist] Joins in Mysql

Judah McAuley judah at wiredotter.com
Wed Dec 26 01:22:10 CST 2001


Hmmm...too tired to expound much on joins (theory and such), but I will 
write the query I think you're trying to use.

SELECT table_1.Password, table_2.other_fields
FROM table_1 INNER JOIN table_2 ON table_1.ID = table_2.ID
WHERE table_1.ID = $form{id}

The INNER JOIN clause of the FROM statement grabs only those rows where the 
ID field in each row matches the ID field in the other table.  And by 
specifying the table_1.ID = $form{id}, the database will pare down the list 
of possible rows in table_1 before joining over to table_2 and searching 
for matching rows over there.  This will make the query pretty fast.

Hope that helps.  Now its time to pass out from Christmas feasting.

Judah

At 04:08 PM 12/26/2001 +1000, you wrote:

>Hi Gang,
>
>I hope someone out there isn't celebrating Christmas so much that they cant
>answer my question (a bit sad really, isn't it)
>
>I have 2 separate tables.
>One table (table_1) has "ID" and "Password" (plus other columns)
>The other table has(table_2) "ID" (plus other columns)
>The "ID"  are identical in both tables
>  I need to be able to confirm that "ID" exists in table_2 and that the
>password given is correct in table_1
>
>Something like:
>SELECT ID,Password from table_2.table_1 where ID=$form{id'}
>
>can you tell I know very little about joins??
>
>Can any body help?
>
>Regards
>
>Adrian Fischer
>
>
>--
>For unsubscribe and other options, including
>the Tip Harvester and archive of TheList go to:
>http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list