| List: | General Discussion | « Previous MessageNext Message » | |
| From: | (Hal | Date: | April 12 2012 2:32pm |
| Subject: | Re: The most elegant/efficient way to pull this SQL query | ||
| View as plain text | |||
>>>> 2012/04/11 17:51 -0500, Peter Brawley >>>>
select b.peopleID, concat('(',p.fname,,')'), b.stateID, concat('(',s.state,')')
from bridge b
join people p on b.peopleID=p.peopleID
join state s on b.stateID=s.stateID;
<<<<<<<<
Since the names are the same in the tables, it works to use "USING", too, and you are
relieved of the burden of an alias:
from bridge
join people USING(peopleID)
join state USING(stateID)
If the fields "peopleId" and "stateID" are the only field names in common, "NATURAL JOIN"
also works.
from bridge
NATURAL join people
NATURAL join state
| Thread | ||
|---|---|---|
| • The most elegant/efficient way to pull this SQL query | Haluk Karamete | 11 Apr |
| • Re: The most elegant/efficient way to pull this SQL query | Peter Brawley | 11 Apr |
| • Re: The most elegant/efficient way to pull this SQL query | hsv | 12 Apr |
| • Re: The most elegant/efficient way to pull this SQL query | Haluk Karamete | 12 Apr |
| • Re: The most elegant/efficient way to pull this SQL query | hsv | 13 Apr |
| • Re: The most elegant/efficient way to pull this SQL query | hsv | 12 Apr |
