Skip navigation links

MySQL Forums :: Newbie :: SELECT items in TABLE 1 but not in TABLE 2


Advanced Search

SELECT items in TABLE 1 but not in TABLE 2
Posted by: coke coke ()
Date: April 16, 2008 01:20AM

Hi again, I'm noob and I'm building a web tool to send custom messages to the users like welcome messages, offer, reminder and so on...

I'm using a simple structure with 3 tables

user:users table,
email: custom messages
posta: history of sended messages

mysql> describe posta;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| email | int(11) | YES | | NULL | |
| dest | varchar(250) | YES | | NULL | |
| data_invio | datetime | YES | | NULL | |
| destid | int(11) | YES | | NULL | |
+------------+--------------+------+-----+---------+----------------+

In the table POSTA I have email (the id of message sended, and destid is the user id receved it).


Now I'm not able to write the right query to know the user list to send the message "April news".

For example...

April news message is in the email table with the id 7, so I check the POSTA TABLE (the history of sended message) and I have 2 user just receved that message. I don't want to send double message to that users!

mysql> select id,email,destid from posta where destid >0;
+----+-------+--------+
| id | email | destid |
+----+-------+--------+
| 72 | 7 | 3 |
| 73 | 7 | 260 |
+----+-------+--------+
2 rows in set (0.03 sec)


I wrote something like that

SELECT user.id from user,posta WHERE user.id != posta.destid and posta.email = 7 group by user.id;

But the result il the complete list of user i have. It is wrong!

Maybe it is simple but I'm noob... can you help me ?



ps. This is a second post I wrote, I hope to have explain my question better then last one, I'm sorry for that becouse I was not able to delete that message [NEWBIE] JOIN... and I don't want to spam this forum with my noob question. Sorry sorry and sorry!

Options: ReplyQuote


Subject Written By Posted
SELECT items in TABLE 1 but not in TABLE 2 coke coke 04/16/2008 01:20AM
Re: SELECT items in TABLE 1 but not in TABLE 2 Peter Brawley 04/16/2008 08:10AM
Re: SELECT items in TABLE 1 but not in TABLE 2 coke coke 04/21/2008 03:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.