DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: best way to build a query

  1. #1
    Join Date
    Mar 2008

    best way to build a query

    i have a table with all records that people say about a product for example

    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


  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    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
    SELECT product_owner_id, id, COUNT(*)
    FROM yourtable
    GROUP BY product_owner_id, id

  3. #3
    Join Date
    Mar 2008
    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, 12:38 PM
  2. SQL2000 remote SQL query
    By lightningtechie in forum Database
    Replies: 1
    Last Post: 02-07-2006, 09: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, 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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center