Hello,

I have the following nested query that I would like to port to Mysql:

****************************************************
SELECT * FROM ad_catego
WHERE db_subcategory NOT IN
(SELECT rules.db_subcategory FROM rules
WHERE rules.db_login='$session_login')
AND db_category_int =2
****************************************************

The query uses two tables

desc ad_catego;
+--------------------+-------------+------+-----+---------+-------+
| Field              | Type        | Null | Key | Default | Extra |
+--------------------+-------------+------+-----+---------+-------+
| db_subcategory     | varchar(30) |      | PRI |         |       |
| db_category        | varchar(15) |      |     |         |       |
| db_category_int    | smallint(6) |      |     | 0       |       |
| db_subcategory_int | smallint(6) |      |     | 0       |       |
+--------------------+-------------+------+-----+---------+-------+

desc rules;
+----------------+-------------+------+-----+------------+-------+
| Field          | Type        | Null | Key | Default    | Extra |
+----------------+-------------+------+-----+------------+-------+
| db_login       | varchar(15) |      | PRI |            |       |
| db_subcategory | varchar(30) |      | PRI |            |       |
| db_daterule    | date        |      |     | 0000-00-00 |       |
+----------------+-------------+------+-----+------------+-------+

I tried several joins without success...  I would like to select all the 
subcategories that a user does not have.

Can anyone help?

Thanks in advance,

Balteo. 

---------------------------------------------------------------------
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

Reply via email to