Jump to content

query spanning 2 tables issue


advancedfuture

Recommended Posts

Okay here is the situation. I have a database with 2 tables, advertisements and users. I want to select all usernames from advertisements table that are advertising in a specific zipcode. It checks the users table to make sure they have the available column set to 0 and the vendor_status colum set to 1. It should then return all usernames with ads running! But I am having problems with my query. Currently what it is doing is printing out the username from BOTH the users table, and the advertisements table!

 

The tables look as follows

Table Advertisements:

username |

advertisement_title |

zip_code

 

Table Users:

 

username |

available |

vendor_status

 

 

The query I am trying to get to work is as follows.

SELECT advertisements.username FROM advertisements, users WHERE users.available='0' AND users.vendor_status='1' AND advertisements.zip_code='95119'

Link to comment
https://forums.phpfreaks.com/topic/140104-query-spanning-2-tables-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.