advancedfuture Posted January 9, 2009 Share Posted January 9, 2009 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' Quote Link to comment https://forums.phpfreaks.com/topic/140104-query-spanning-2-tables-issue/ Share on other sites More sharing options...
abdfahim Posted January 9, 2009 Share Posted January 9, 2009 SELECT advertisements.username FROM advertisements, users WHERE users.available='0' AND users.vendor_status='1' AND advertisements.zip_code='95119' AND users.username=advertisements.username Quote Link to comment https://forums.phpfreaks.com/topic/140104-query-spanning-2-tables-issue/#findComment-733082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.