Jump to content

Is it possible to search one table while using another as a condition?


pault

Recommended Posts

(PHP version 5.2.14)

 

My situation is that I have table of Users and a table of Adverts which are created by those Users. I want to search the Adverts, selecting for for dates, price, etc, which is all very straightforward. The difficulty comes in that the Users are sometimes enabled and sometimes disabled, and when they are disabled, none of their adverts should appear.

 

What I need then is something like "select * from Adverts where (adverts.dates=etc, etc) AND where User.enabled=true"

 

I've been looking at joins and subqueries but the examples don't seem to match what I am looking for. Grateful for any help.

Link to comment
Share on other sites

most likely possible...

 

I want to search the Adverts, selecting for for dates, price, etc, which is all very straightforward

 

post the code that you are using for that.... and additional your table's definitions

 

a simple join should solve your issue if your table design is correct.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.