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 > Determining number of rows in a category from another table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-04, 21:40
JohnSaunders JohnSaunders is offline
Registered User
 
Join Date: May 2004
Posts: 1
Determining number of rows in a category from another table

I'm using the following code to get the number of rows from a table that are in a specific category. For some reason it keeps saying there's one row when there's only two rows in the category. There's one a different category (not 6) and the menu status is set to 0, but it's still returning a result of 1. Can anybody find an error in my statement?

Code:
	SELECT count(customer.category_id)
          FROM customer
    LEFT OUTER
    	  JOIN menu
	    ON menu.customer_id = customer.id
	   AND menu.status = '1'
    LEFT OUTER
	  JOIN category
	    ON category.id = customer.category_id
	 WHERE customer.category_id = '6'
Also, is there anyway to visualize what it's doing when running statements? Like seeing the tables how they look when they are joined?
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