OT: MySQL syntax help

Alex Dean alex at crackpot.org
Tue May 16 21:10:12 MST 2006


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.


More information about the PLUG-discuss mailing list