That's pretty hard to do; you haven't said what the query is trying to do and you haven't supplied definitions of the tables you are using or provided a few rows of sample data so that we could form a mental picture of what you are trying to accomplish. Also, you haven't stated what version of MySQL you are using; if you are using a version prior to 4.1.x, subqueries aren't possible at all.
Nevertheless, assuming that subqueries *are* possible in your version of MySQL, I can make an educated GUESS. The WHERE clause of your subquery looks wrong, particularly "messages.id". I would expect the WHERE to be constructed with one of the following: - with a constant, e.g. WHERE message_id = 10 - in the case of a correlated subquery, with another column name that refers back to the outer query, e.g. "WHERE message_id = x.message_id" (in this case, the correlation name, 'x' in this case, would also need to appear in the FROM clause of the OUTER query.) - in the case of a join, with another column name, e.g. WHERE a.message_id = b.message_id Your WHERE clause doesn't follow any of those patterns. I assume that's what MySQL doesn't like. Rhino ----- Original Message ----- From: "Herman Scheepers" <[EMAIL PROTECTED]> To: <mysql@lists.mysql.com> Sent: Sunday, November 13, 2005 11:53 AM Subject: Sub Query > Hi > > Could anyone help perhaps tell me why the following > simple query containing a sub-query gives a syntax > error. > > select 1 from messages > where not exists ( select 1 from > message_push_notifications > where message_id = > messages.id) > > > Thanx > Herman > > > > > __________________________________ > Start your day with Yahoo! - Make it your home page! > http://www.yahoo.com/r/hs > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.362 / Virus Database: 267.13.0/167 - Release Date: 11/11/2005 > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.0/167 - Release Date: 11/11/2005 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]