Re: OT: MySQL syntax help

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Alex Dean
Date:  
To: Main PLUG discussion list
Subject: Re: OT: MySQL syntax help
On May 16, 2006, at 9:43 AM, Kevin wrote:

> Sorry for the tangent here, but I know there are some SQL guru's
> here and
> I'm in a real bind (no pun intended!).
>
> I have two tables in a MySQL database.
>
> Table1
> ID ~ Kernel
> 01 ~ 2.4.19
> 02 ~ 2.4.21
> 03 ~ 2.6.4
> 04 ~ 2.6.9
> [snip]
>
> Table2
> ID ~ hostname ~ kernel ~ arch
> 01 ~ web001AZ ~ 2.4.19 ~ x86
> 02 ~ web002AZ ~ 2.4.21 ~ x86
> 03 ~ web003AZ ~ 2.6.12 ~ sparc
> [snip]
>
> I need a query to pull every row from Table2 where the "kernel" field
> matches ANY row in Table1. Any ideas???


Wouldn't a simple inner join achive this goal, without the overhead
of a subquery?

SELECT
table2.*
FROM table2
INNER JOIN table1 USING (kernel)

Any rows that can't be joined won't be included.
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss