[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] MySQL Question



On Thu, Apr 01, 2004 at 09:08:38AM -0500, Yu, Jerry wrote:
> Not sure what exactly do you mean by 'to speed this up'...
> 
> 
> To answer the question of 'consolidate into one SQL statement"
> 1) use subqueries:
> select * from users where ID in ( select User_ID from ALARMS where ID = 1 );
> 
> or 2) define a view.

YUCK!  Are you coming from MS SQL Server or something? ;p 

What's wrong with a join?

select * from users inner join ALARMS on users.user_id = ALARMS.user_id WHERE ALARMS.ID=1;

Using nested SELECT statements when a join is the right tool for the job is.. nasty.

Cheers,
--George