list only the ads that have not been sent request

0

I have the following doubt,

We are working on a system of classified ads, users log in and access classified ads of the company, they can send requests to the ads if they are interested (for example in the case of job vacancies).

If the user decides to send a request, a record is created in the requests table.

In the ads table are all the attributes of the ads, title, description, statusAnnouncement, publication date ...

In the table requests on the other hand there is a record for each request that is sent to the ad, the fields of this table are: idApplication, idAnnounce, idPersona, idEmpresa, estadoPersona, estadoEmpresa ... The field idPersona is FK with The people table and the Company id field is FK with the companies table.

I need to list only the ads to which the user has NOT sent the request, that is, if this user has already sent a request to an advertisement that ad will not appear in the query. . How could I do it?

    
asked by Eddy Mazzo 23.05.2016 в 22:15
source

1 answer

0

You should make a query showing the records in the Ads table whose idAnnouncement is not in the Requests table associated with the person.

For example for idPersona "1" it would be something like this:

SELECT * FROM Anuncios
WHERE idAnuncio NOT IN 
  (SELECT idAnuncio FROM Solicitudes WHERE idPersona=1);
    
answered by 23.05.2016 в 22:32