mysql help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flapjack
Forum Newbie
Posts: 14
Joined: Fri May 29, 2009 8:09 pm

mysql help

Post 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?
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: mysql help

Post 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....
flapjack
Forum Newbie
Posts: 14
Joined: Fri May 29, 2009 8:09 pm

Re: mysql help

Post 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.
Post Reply