DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008
    Posts
    164

    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)

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    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
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Mar 2008
    Posts
    164
    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

  1. Union query
    By peljo in forum Database
    Replies: 4
    Last Post: 12-17-2007, 11:38 AM
  2. SQL2000 remote SQL query
    By lightningtechie in forum Database
    Replies: 1
    Last Post: 02-07-2006, 08:34 AM
  3. Build easy. Build fast. Build smart. Visual Build Professional.
    By Kyle Alons in forum java.announcements
    Replies: 0
    Last Post: 04-28-2003, 09:36 AM
  4. Help me out to build the query
    By ganesh in forum Database
    Replies: 0
    Last Post: 12-10-2001, 10:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links