/    Sign up×
Community /Pin to ProfileBookmark

Help: Alpha Order Table Based On Other Table?

I have one db table “equipment” with a field called “equipManu”. This field is populated with an id# from another table call “manufacturers.” The issue is when I want to sort the equipment table by manufacturer. When I ORDER BY equipManu, it orders by the ID number that populates that field and not the manufacturer name that the ID# is associated with. Is there a way it can order alpha by the manufacturer NAME from that other table? I bet this is an easy solution…

equipment
————

equipID(int)
equipManu <– Uses manuID from manufacturers

manufacturers
—————-

manuID(int)
manuName <– Want to alpha order by this value

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Mar 17.2004 — you need to change your query:

<i>
</i>
select equipment.*, manufacturers.manuName from equipment
inner join manufacturers on manufacturers.id=equipment.equipManu
order by manufacturers.manuName;
Copy linkTweet thisAlerts:
@msmith29063authorMar 17.2004 — Works like a charm. Thank you for your help.
Copy linkTweet thisAlerts:
@crh3675Mar 17.2004 — You're welcome
×

Success!

Help @msmith29063 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...