Hi all, I have two tables containing the following:
table1: +----------------------------------+--------------------+ | UNID | DATE | +----------------------------------+--------------------+ | 08294D5D0F9ABE6D46663300BDB6521C | 2001-09-09 02:00:30| | FF4210F70A19D36856663300BDB6521C | NULL | | FB499B109E1C6E1466663300BDB6521C | NULL | | 9429E5EC91F7508676663300BDB6521C | NULL | | 578313DA1378F96E86663300BDB6521C | 2001-10-21 02:00:40| ... etc .... etc .... table2: +-----+----------------------------------+-------------------+----------------------------------+ | ID | PO_UNID | CONTENT | PO_DOCID | +-----+----------------------------------+-------------------+----------------------------------+ | 519 | 08294D5D0F9ABE6D46663300BDB6521C | on | D6EBA9F0D5D49280C1256BDB00336664 | +-----+----------------------------------+-------------------+----------------------------------+ | 520 | 08294D5D0F9ABE6D46663300BDB6521C | off | DFAEFFFWE33771FSDSF428DSF3559999 | +-----+----------------------------------+-------------------+----------------------------------+ My problem is that the following query results in several thousand tupels: SELECT UNID FROM TABLE1 WHERE DATE IS NULL; Therefore I use: SELECT UNID FROM TABLE1 WHERE DATE IS NULL LIMIT 1; Now I want to do the following: SELECT UNID FROM TABLE1 WHERE DATE IS NULL LIMIT 1; SELECT CONTENT FROM TABLE2 WHERE PO_UNID='<RESULT PREVIOUS QUERY>' Instead of writing two queries this could be written as: mysql> select 0.UNID, c.CONTENT -> from table1 o, table2 c -> where o.DATE IS NULL -> and o.UNID = c.PO_UNID -> LIMIT 1; This results query gives me the right result but it's execution time takes allmost 6 times longer then the two seperate queries. I'm planning to make these queries in a JAVA program (Using the JDBC-bridge). Which variation is smarter? Using the 2 queries, or using the second variation met the join? Any help would be greatly appreciated. Many Thanks, Harm de Laat Informatiefabriek The Netherlands --------------------------------------------------------------------- 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