aliento Posted January 12, 2010 Share Posted January 12, 2010 Hi, I have two queries which i want to take them both . $sql = "SELECT `id` FROM `ads` WHERE `state_id` = '$state_id' ; SELECT `id` FROM `ads` WHERE `state_id` = '$state_id' AND `category_id` = '$category_id';" I want to make them both in one query but i have lack of knowledge . Quote Link to comment https://forums.phpfreaks.com/topic/188184-where-question/ Share on other sites More sharing options...
cags Posted January 12, 2010 Share Posted January 12, 2010 I don't understand your objective. The second query appears to be exactly the same as the first query only being more specific (the category_id must match as well as the state_id), since the first query will return all values from a specific state and the second query also requires values from the same state, the second query will only ever return rows that have already been found by the first, thus making it seem a little redundant. Quote Link to comment https://forums.phpfreaks.com/topic/188184-where-question/#findComment-993495 Share on other sites More sharing options...
aliento Posted January 12, 2010 Author Share Posted January 12, 2010 my mistake , i was a little cloudy but you helped me think clearer. I found the solution. Quote Link to comment https://forums.phpfreaks.com/topic/188184-where-question/#findComment-993498 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.