Jump to content
thirty bees forum
  • 0

MySQL Table list


Minimonkay

Question

Hey all,

I'm beginning to build my own SQL Queries to get information from orders etc.
Having a lot of fun, but struggling with the prefix's used. For example I've worked out that the g. prefix is connected to customer information table, but how can I find out the prefix's used for all the other tables?

I've searched for ages and I can't find anything.

Thanks,
Sam

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Apologies guys and gals. I think I've figured it out.

 

Here's a part of a query I've found by a helpful forum member:

 

 

 

SELECT d.id_order, o.payment

 

    FROM order_detail d

 

    LEFT JOIN orders o ON (d.id_order = o.id_order)

 

 

 

My question was referring to the d and the o before the id_order and payment respectively from SELECT. After some fiddling about I've discovered these are specified after the tables being referenced in the FROM and LEFT JOIN parts. I.e. you change the 'd' after 'order_detail' to another letter, and then the 'd' before 'id_order' to match and it works.

 

In short there is no 'prefix' that exists outside of this specific query.

Is this correct?

Sorry for trying to run before i can walk and bothering everyone. I should learn the language.

Link to comment
Share on other sites

  • 0

The thing you are talking about is named "alias". For each table you can and should specify it. But you do that in each query and you can chose whatever alias you want.

This is needed if two tables have the same column_name. Imagine if you select all categoroies with all their products. Select name would not tell, if you want the product name or the category name.

Thats why you would use something like

Select c.name AS category_name, p.name AS product_name

FROM category_table AS c

JOIN product_table AS p on p.id_category=c.id_category

 

Note: This is just an abstract example. "AS" is normally not needed, but it makes things much more clear for beginners.

Edited by wakabayashi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...