A client needs a sales report by country state/province. There is an orders table that stores the customer's country and state/province, and there is an orders_products table that stores the order to product association and the product's price. 
The client wants the following statistics per country & state/province: total sales, % sales...
            
           
          
            
            Hi all
I have problem using REGEX in Mysql
I have oid value in database like this
id  ->  value
1.3.6.1.4.1 ->  Value a 
1.3.6.1.4.1.2499.1.1.2.1.1.1.1.1    ->  Value b
1.3.6.1.4.1.2499    ->  Value c
And my objecttives are
1. To get single oid & value with the specific oid that i put into sql statement
2. If no specific value the...
            
           
          
            
            I am getting syntax error in following statement...but I want to use it by USING STATEMENT.
  SELECT
  user_job.level1,user_job.tab_level,job.money_gain,job.exp_gain,job.energy_required,job.name,job_tem.no
  LEFT JOIN job USING(job_id) AND LEFT
  JOIN job_item USING(job_id)
  
  job_id is common in all the tables.
...
            
           
          
            
            Hello I am bit of a newb when it comes to mysql I running a query and I am getting the following error, to my knowledge the query syntax is correct (obvioulsy not though) this is the error that I am getting, 
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your  
 MySQL server version for the right...
            
           
          
            
            my table look like this 
  
Name     Created
ganesh   2010-06-25 10:54:54 
vasant   2010-06-25 11:54:54 
charlie  2010-06-25 12:54:54 
sam      2010-06-25 13:54:54 
vasamtj  2010-06-25 01:54:54 
jack     2010-06-25 02:54:54 
nima     2010-06-24 10:54:54 
kumar    2010-06-24 10:54:54 
jay      2010-06-24 10:54:54 
paala    2010-06-23 ...
            
           
          
            
            Is there a way to get a count of groups in mysql?
For example I have 4 rows
cat1
cat2
cat1
cat3
I would like a count of categories, i.e 3
Is this possible?
Thanks
...
            
           
          
            
            using latest mysql server,
after some period of inactivity my website sqls times out (only some not all)
these queries are not newly written existing queries. 
Testing results
when execute a simple sql like (select count(*) from products) this works fine all the time.
when execute below sql
SELECT products.pid FROM products INNER JO...
            
           
          
            
            Hello,
I have 3 tables;
game, platform, game_platform
game
id    name               desc
----  ------------       ---------
1     Modern Warfare...  Awesome game......
2     ...                ...
3     ...                ...
platform
id    name
----  ------------
1     pc
2     ps3
3     ...
game_platform
game_id    platform_i...
            
           
          
            
            Is there any way I can get the actual row number from a query?
I want to be able to order a table called league_girl by a field called score; and return the username and the actual row position of that username.
I'm wanting to rank the users so i can tell where a particular user is, ie. Joe is position 100 out of 200.
Ie.
User Score ...
            
           
          
            
            I am storing hierarchical data in mysql in the form of a nested set.
myTable
  id,
  title,
  lft,
  rgt
I use the following series of sql statements to insert a new node:
SELECT @myLeft := lft FROM myTable WHERE ID = $id;  
UPDATE myTable SET rgt = rgt + 2 WHERE rgt > @myLeft;       
UPDATE myTable SET lft = lft + 2 WHERE lft > @myL...
            
           
          
            
            I have several tables I need to query in order to get all the rows for a certain user.
The tables basically look like this
contact
=======
id_contact PK
firstName
lastName
...
contact_phone
===============
id_contact_phone, PK
id_contact, FK
id_phone_type, FK
phone
...
phone_type
============
id_phone_type PK
phone_type
....
And the...
            
           
          
            
            Hello,
I'm trying to get data from two MySQL tables, but having problems.
Usually, I'd use join to get data from two those tables depending on data, but this time I cannot, I think.
Here's situation:
I'm having tables photos and photos_albums.
photos ID ALBUM FILENAME
photos_albums ID TITLE NAME
I need to get all albums and photo i...
            
           
          
            
            I tried to use this function
        $conn = db_connect();
        while ($newsfeed = $conn->query("select info, username, time from newsfeed ORDER BY time DESC LIMIT 10"))
        {
                    (...)
                     echo "<p>User $newsfeed_username just registerted ".$minutes." min ago </p><br>";
but it only shows the la...
            
           
          
            
            I have written query, I wanted to know the effect of usage of IN clause in Query.
Query I
Select * from khatapayment_track 
Where Property_ID IN (Select Property_id from khata_header where DIV_ID=2)
Query II
Select * from khatapayment_track KPT, khata_header KH
Where kh.Property_id=KPT.Property_id and KH.DIV_Id=2
I would like to know ...
            
           
          
            
            I would like to copy data from an existing table say table1 to a new table table2.  The tables' engines are different. I mean, the existing table uses MyISAM and the new one uses Innodb.
...
            
           
          
            
            I have this query:
SELECT p.text,se.name,s.sub_name,SUM((p.volume / (SELECT SUM(p.volume) 
                FROM phrase p
                WHERE p.volume IS NOT NULL) * sp.position))
AS `index`
FROM phrase p
LEFT JOIN `position` sp ON sp.phrase_id = p.id
LEFT JOIN `engines` se ON se.id = sp.engine_id
LEFT JOIN item s ON s.id = sp.site_id
...
            
           
          
            
            SELECT DISTINCT rt . d_rev_id , rt . d_rev_code , rt . d_reason , rt . d_rev_status , rt . d_apb , rt . d_cb , pt . d_partid , pt . d_part_no , pt . d_ab , pt . d_abd , pt . d_status , rt . d_part_name , rt . d_part_desc , rt . d_part_type , pnv . d_pn_val , pnv . d_pn_id , cfv . d_optionname , rt . d_projectid , rt . d_abd , rt . d_apbd...
            
           
          
            
            Hi,
I have a MySQL UPDATE query which takes a long time to complete. Am I missing a much simpler way to achieve the same result?
"UPDATE table2, table1
SET table2.id_occurrences = (SELECT SUM(IF(id = table2.id, 1, 0)) FROM table1)
WHERE table2.id = table1.id;"
table2 contains all possible values of id, exactly one record for each.
t...
            
           
          
            
            Hello, 
i have the following table structure
table "location" has
    - id
    - parentLocation_id (relation to itself)
    - name
let assume we have the following data:
id  parentLocation_id  name
1         null           Egypt
2          1             Cairo
3          2             Zamalek
here we have three levels of locations ,...
            
           
          
            
            I am having trouble with an automatically generated SQL query, that is based on several smaller queries stored in a table, and combined with what the user inputs.
I will show the inputs for a query that works, and then the query itself.
I will then show my inputs, and the query that fails.
If someone could point me what input I have u...