abdelelbouhy Posted August 7, 2013 Share Posted August 7, 2013 (edited) Hi guys, i have two tables products and deleted_products i want to select products_id from the two tables where the field suspend = 1 but there's no relationship between the tables in other words i want all the products_id from the tables where suspend = 1 but the products_id in table one doesn't match produtcs_id in table 2 the only relationship i can find is the suspend in both tables is 1 my query string is like that select p.products_id as PID, dp.products_id AS PDID FROM products p, deleted_products dp WHERE p.suspend = dp.suspend and p.suspend = 1 it return zero result but the two tables have products with suspend = 1 thanx Edited August 7, 2013 by abdelelbouhy Link to comment Share on other sites More sharing options...
niche Posted August 7, 2013 Share Posted August 7, 2013 (edited) No relationship (between your tables) = no join with sql. However, you can select both tables with two different queries and combine their results with PHP. Edited August 7, 2013 by niche Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2013 Share Posted August 7, 2013 Use a union, that's what they're for. SELECT product_id FROM table1 WHERE suspend=1 UNION SELECT product_id FROM table2 WHERE suspend=1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now