-
best way to build a query
hi,
i have a table with all records that people say about a product for example
table:xxx
field: id , date, comment, product_owner_id
imagine that i have 100 records of comment for a product and 250 for other product and none for other product and now i want say that:
owner 1 have:
-product 1 have 100 records
-product 2 have 250 records
-product 3 have 0 records
owner 2 have:
-product 1 have 0 records
-product 2 have 0 records
-product 3 have 110 records
and so long, there is a way to build a simple query that donīt spend very resource of cpu? the db that i using is mysql
thanks a lot for your help
(Rate)
-
An output of 0 would be difficult insofar as those records don't exist. I suppose you could check to see if there was a return, and if not, programmatically list them as 0.
Anyway, for those records that do exist, try
Code:
SELECT product_owner_id, id, COUNT(*)
FROM yourtable
GROUP BY product_owner_id, id
-
hi.
thanks a lot for your help this works lilke i wanted 
i have more one question that may be this place is not the best...
i want save a value in real time using php/ajax/javascript/mysql
imagine this: you have a list of items and want check the items that you liked and them when you select/unselect the items they are saved in real time into mysql db i have see same like this working with cookies and not for all browsers i have see other way to do this not save but get the value without submit or reload the page any one know how can i do that?
the ideia is save a value of a checkbox for example when i check/uncheck them when i want consult the items that i have checked they will prompt a list that is saved in db
thanks for your help
Similar Threads
-
By peljo in forum Database
Replies: 4
Last Post: 12-17-2007, 12:38 PM
-
By lightningtechie in forum Database
Replies: 1
Last Post: 02-07-2006, 09:34 AM
-
By Kyle Alons in forum java.announcements
Replies: 0
Last Post: 04-28-2003, 09:36 AM
-
By ganesh in forum Database
Replies: 0
Last Post: 12-10-2001, 11:57 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|