If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > mySQL codde to join Cat,SubCat,SubSubCat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-06-09, 11:23
chinalinda chinalinda is offline
Registered User
 
Join Date: Aug 2009
Posts: 4
Question mySQL codde to join Cat,SubCat,SubSubCat

I already have a search field on my website by following a tutorial on Pixeldigest.com. I have also learned the creation of tables and the connection of them in Dreamweaver to mySQL database.
I will try to explain you the problem on a very simple way.
I have Customers and I publish they business advertising on my web pages. If someone is searching for a particular word on my page, I want on the Result_Page all customers related to their
“Category” “Sub-Category” and “Sub-Subcategory”
Note: Below I wrote the idea
I do understand Primary Keys, Foreign Keys, Indexing, Table Creation, and Connections but….
How many tables do I need?
What field and on which TBL and how to make a relationship?
Which TBL is Child and which is Parent?
Where each FK goes?
How do I write mySQL code in Dreamweaver? SELECT, JOIN, OR, AND, LEFTJOIN, etc.

This is what I have at this time, but I do not know what to do with it.

TBL_1 CUSTOMER_NAME & CUSTOMER_IMG (George Sporting Goods) (Banner)
TBL_2 CATEGORY: (Sports)
TBL_3 SUB_CATEGORY: (Baseball)
TBL_4 SUB_SUB_CATEGORY (Baseball Bat)
Reply With Quote
  #2 (permalink)  
Old 08-06-09, 11:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
hello george

have a look at this article --
Categories and Subcategories

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-06-09, 13:12
chinalinda chinalinda is offline
Registered User
 
Join Date: Aug 2009
Posts: 4
Thank you for your prompt response. I will look at the link you sent me.
Reply With Quote
  #4 (permalink)  
Old 08-06-09, 13:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by chinalinda
Thank you for your prompt response. I will look at the link you sent me.
dear chinalinda

you should have looked at it yesterday, when i gave it to you after you emailed me the exact same question under the name of George Torres

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 08-06-09, 14:25
chinalinda chinalinda is offline
Registered User
 
Join Date: Aug 2009
Posts: 4
I was reading the article, but it is to advaced for me at this time. Even I do understand the whole idea I can't do it myself without help. Please could you write for me the code. I mean SELECT tbl, etc,etc..
Thank you
Reply With Quote
  #6 (permalink)  
Old 08-06-09, 14:42
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by chinalinda
I was reading the article, but it is to advaced for me at this time. Even I do understand the whole idea I can't do it myself without help. Please could you write for me the code. I mean SELECT tbl, etc,etc..
Thank you
give it a try yourself, and i will help if you get stuck

start by writing the query to display all categories, subcategories, and subsubcategories

hint: this query is already given to you in that article
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 08-07-09, 20:42
chinalinda chinalinda is offline
Registered User
 
Join Date: Aug 2009
Posts: 4
Red face mySQL search nightmare

SELECT customers.customername,categoria2.categoria2,categ oria.categoria
FROM customers,categoria2,categoria
WHERE customers.categoria=categoria.categoria

This is the result

customername categoria2 categoria
george angels work Mecanicos de automotores
smith angels work Mecanicos de automotores
george bodyshop Mecanicos de automotores
smith bodyshop Mecanicos de automotores
george curandero Mecanicos de automotores
smith curandero Mecanicos de automotores
george reparacion de carros Mecanicos de automotores
smith reparacion de carros Mecanicos de automotores
Reply With Quote
  #8 (permalink)  
Old 08-07-09, 22:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
that output is from your test database, yes/

please mysqldump the tables, or Export them if you are using a front-end application like phpmyadmin -- both structure and data, please (i.e. both CREATE TABLE and INSERT statements)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On