Have you tried using a JOIN as a way of eliminating the subquery?

If I understand you correctly, you are looking for certain items from
table1 only if there is no corresponding entry in table2. Am I close?

You would write that generally as:

SELECT <field names from either table>
FROM table1
LEFT JOIN table2
ON <logical statement that pairs up rows of table1 to rows of table2>
WHERE <any column of table2 (it doesn't matter which)> is null
AND <other conditions, as necessary>

I could get more specific but I don't have enough details about your
tables.

Yours,
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



                                                                                       
                                   
                      "Mark van Beek"                                                  
                                   
                      <[EMAIL PROTECTED]        To:       <[EMAIL PROTECTED]>          
                                
                      il.com>                  cc:                                     
                                   
                                               Fax to:                                 
                                   
                      06/10/2004 01:35         Subject:  mysql 3, subquerie 
alternative                                   
                      PM                                                               
                                   
                                                                                       
                                   
                                                                                       
                                   




Hi,



For a project I'm creating a search function, the deal is this, a select
query must be submitted and in this query a check must be done to confirm a
previously found and accepted item is not shown anymore, a short version of
the query I need is this:



SELECT * FROM t1 WHERE {all kinds of limits} AND 0 = (SELECT count(*) FROM
t2 WHERE field1=t1.field1 AND field2={fieldvalue}) LIMIT 0,20;



I don't know if the above query gives the result I want for starters, but
if
someone gets the idea and know a way to implement a query like this in
mysql
3 instead of mysql 4.1+ I'd like to know. I cannot just upgrade to mysql
4.1+ since the database is on a rented server and I'm just the geek trying
to fix some things on the site.



Greetings Mark









-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to