MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 14th, 2013, 03:03 PM
backbencher backbencher is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 7 backbencher New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 2 h 49 m 6 sec
Reputation Power: 0
Joining tables in MySQL

I have 2 tables with company names (around 1,000 companies) and products (20,000 products).

I am looking to create a table which would have all products against each companies. eg. "company#1" in column A each in rows 1 to 20k... and "products#1 to 20,000" in column B
similarly for company#2" and so on

- so I would have 1,000*20,000 = 20,000,000 records in table.

Thanks

Reply With Quote
  #2  
Old March 14th, 2013, 10:04 PM
diawilliam diawilliam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 diawilliam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 12 sec
Reputation Power: 0
Joining tables in MySQL

You can use Union to get the type of result you wanted.

Reply With Quote
  #3  
Old March 15th, 2013, 01:00 AM
backbencher backbencher is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 7 backbencher New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 2 h 49 m 6 sec
Reputation Power: 0
Thumbs up Error Code: 2008 MySQL client ran out of memory

I have created DB (myDatabase) with 3 tables (Table1, Table2, Table3) each tables have 1 column - namely company, product1 and and product2 respectively.

table1 has 5 records
table2 has 6000 records
table3 has 2000 records

I am now using below query to create another table and join the results from all 3 tables - which would fetch me 60,000,000 rows (ie 5 * 6000 * 2000). (I know thats huge but I want all records for some analytics)

However when I am running the query I am getting "Error Code: 2008 MySQL client ran out of memory". I am using MySQL workbench on my PC (Win 7-64 Bit, 8GB RAM and 600 GB free HD space) to run the code.

Also if I change the limit (in below code) to lower number (say 1000) it executes the code and shows me results on screen but it does not insert the results into "myNewtable"

Can someone help please.

Create Table myDatabase.myNewtable ( SrNo INT NOT NULL AUTO_INCREMENT PRIMARY KEY, company VARCHAR(255), product1 VARCHAR(255), product2 VARCHAR(55) ); Select table1.company, table2.product1, table3.product2 from myDatabase.table1, myDatabase.table2, myDatabase.table3 LIMIT 0,99999999

Reply With Quote
  #4  
Old March 15th, 2013, 01:35 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,373 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 54 m 49 sec
Reputation Power: 4140
Quote:
Originally Posted by backbencher
Also if I change the limit (in below code) to lower number (say 1000) it executes the code and shows me results on screen but it does not insert the results into "myNewtable"
your SELECT is a separate statement from your CREATE TABLE

you can define the CREATE TABLE including the SELECT as one statement (by removing the semicolon between them), but i would not do that, because after you've processed a few rows with your LIMIT, you're still going to have to use an INSERT SELECT statement for the remainder

so CREATE the table, and then just start using INSERT SELECT statements
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #5  
Old March 15th, 2013, 02:28 AM
backbencher backbencher is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 7 backbencher New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 2 h 49 m 6 sec
Reputation Power: 0
Quote:
Originally Posted by r937
your SELECT is a separate statement from your CREATE TABLE

you can define the CREATE TABLE including the SELECT as one statement (by removing the semicolon between them), but i would not do that, because after you've processed a few rows with your LIMIT, you're still going to have to use an INSERT SELECT statement for the remainder

so CREATE the table, and then just start using INSERT SELECT statements


Thanks a lot mate... that helped!
...after 1050 secs I got my data..

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Error Code: 2008 MySQL client ran out of memory

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap