> I'm trying to use the "IN" operator as described in my databases textbook > from college. This query: > > select count(*) from user where user.ID in (select ID from user); > > is supposed to evaluate to "count the number of rows in the 'user' table > where the ID field is in the set of all ID field values in the 'user' > table" (in other words, just a roundabout way of counting the rows in the > 'user' table, written solely to demonstrate the "IN" keyword). > > There doesn't seem to be a syntax error in that example, but MySQL gives > the error: > > ERROR 1064: You have an error in your SQL syntax near 'select ID from > user)' at line 1 > > Is the "IN" keyword not supported in MySQL, or am I using it wrong?
It is and you are -- IN is supported, but subselects aren't. So you can use IN with a value list, i.e. select count(*) from user where user.ID in (4, 101, 1000); but not in the context you describe. / Carsten -- Carsten H. Pedersen keeper and maintainer of the bitbybit.dk MySQL FAQ http://www.bitbybit.dk/mysqlfaq --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php