Page 1 of 1

mysql help

Posted: Fri May 14, 2010 10:51 pm
by flapjack
hello,

I am embarking on new territory by advancing my skills in mysql.

I am currently working with LEFT JOIN, but while I was working on example, I noteced that the example was almost renaming the table while running the query...see the following...

My database has the following tables
company category company.category

the mySQL query looked like this:

SELECT ct.name FROM category ct
LEFT JOIN company_category cc ON ct.id = cc.category_id
LEFT JOIN company c ON cc.company_id = c.id
WHERE c.id = 2

so, this snippet: category ct
and this: ct.name

whats up with that? Where does the CT come in to play?

Re: mysql help

Posted: Sat May 15, 2010 12:34 am
by mikosiko
flapjack wrote:SELECT ct.name FROM category ct
LEFT JOIN company_category cc ON ct.id = cc.category_id
LEFT JOIN company c ON cc.company_id = c.id
WHERE c.id = 2
table category.... ALIAS/SHORT NAME ct
table company_category .... ALIAS/SHORT NAME cc

and so on....

Re: mysql help

Posted: Sat May 15, 2010 8:24 am
by flapjack
THanks alot. So simple.

I was assuming that was what it was, but didn't want to mess it up in a job interview.