If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > I want get category name and no of products inside each of...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-10-10, 02:37
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
I want get category name and no of products inside each of...

is this query correct
Code:
SELECT Products.count(*), Categories.Category FROM Products GROUP BY Category_ID INNER JOIN Categories ON Categories.Category_ID = Products.Category_ID
count(*) of products === number of products in each Category
I want get category name and no of products inside each of...
Reply With Quote
  #2 (permalink)  
Old 11-10-10, 05:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by lse123 View Post
is this query correct
what happened when you tested it?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-10-10, 05:21
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
null ... error pupulate arrays...js population ..I want to populate php arrays and there after javascript arrays with the two fields...
Reply With Quote
  #4 (permalink)  
Old 11-10-10, 05:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by lse123 View Post
null ...
here's a hint: the query contains a syntax error, and running the query outside of php, directly in the mysql engine, will produce an appropriate error message which will help you fnd the source of the problem

that's what i meant by testing it

you want to test the query itself, and not the application logic to build an array or whatever
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 11-10-10, 07:31
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
mind you you should have got soe sort of error message from the PHP/MYSQL interface
did you examine the MySQL_Err & MySQLErrNo?
Google
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On