|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Here's the basic statement:
SELECT * FROM `log` LEFT JOIN (`ticket`, `responder`) ON `log`.`ticket_id` = `ticket`.`id` AND `log`.`responder_id` = `responder`.`id`; That works. Now I'd like to alias a number of fields in the 'joined' tables, ticket and responder. How do I express an alias of, say, ticket.name or responder.status? Thanks, all. -AS |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
== Quote from ashore (shoreas@gmail.com)'s article
> Here's the basic statement: > SELECT * FROM `log` LEFT JOIN (`ticket`, `responder`) ON > `log`.`ticket_id` = `ticket`.`id` AND `log`.`responder_id` = > `responder`.`id`; > That works. > Now I'd like to alias a number of fields in the 'joined' tables, > ticket and responder. How do I express an alias of, say, ticket.name > or responder.status? > Thanks, all. > -AS the alias would be on the table. your statement would look like this: select * from log a left join (ticket b, responder c) on a.ticket_id = b.id and a.responder_id = c.id you see how it is cleaner and shorter. -- POST BY: lark with PHP News Reader ;o) |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Yes, but ... .
How do I express a fieldname alias, not a tablename. (E.g., b.name or c.status) ? thanks again. AS |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Hey, I played with it and got it. I didn'tr realize MySQL was smart
enough to sort-of backtrack in the parsing process. Thanks. -AS |
|
![]() |
| Outils de la discussion | |
|
|