scotchegg78 Posted August 27, 2007 Share Posted August 27, 2007 hey guys I have to count the rows so use $query = "SELECT COUNT(LeadID) AS numrows FROM lead, company " . $query_qryDatacount; i need company as the additional quety may have filters from this table at times and sql errors if i leave it out and filters are selected. But the problem is my row count is lead * company !? and example of a filter on the query is SELECT COUNT(LeadID) AS numrows FROM lead, company WHERE NetworkID LIKE '3' but as i say, the row count is both tables multiplied together, all i want is the total leads that use a companyid on a network 3. with me? cheers ma dears. Quote Link to comment https://forums.phpfreaks.com/topic/66948-mysql-count-issue-when-where-uses-two-tables/ Share on other sites More sharing options...
Illusion Posted August 28, 2007 Share Posted August 28, 2007 U missed where condition.... where lead.leadid=comapny.leadid and NetworkID LIKE '3' ; Quote Link to comment https://forums.phpfreaks.com/topic/66948-mysql-count-issue-when-where-uses-two-tables/#findComment-336039 Share on other sites More sharing options...
fenway Posted August 28, 2007 Share Posted August 28, 2007 It's a JOIN condition... use a proper JOIN and it will be obvious you're missing the on clause. Quote Link to comment https://forums.phpfreaks.com/topic/66948-mysql-count-issue-when-where-uses-two-tables/#findComment-336132 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.