Kind gentlemen / ladies,
Here are the two tables I am working with ... the important columns at least --
Table #1 - items (catid -- which contains the ID# of whatever category it is from table #2)
Table #2 - categories (id,name)
I want to be able to display a search results page that allows me to sort in alphabetically ascending order all the pertinent information from Table #1 but based on the NAME column from Table #2.
So basically:
Select everything from items,categories order by categories name
Any assistance would be greatly appreciated, thanks.
2 Table MySql Query Assist
Moderator: General Moderators
Re: 2 Table MySql Query Assist
Code: Select all
SELECT * FROM [i]items[/i] JOIN [i]categories[/i] ON categories.id=items.id
ORDER BY nameRe: 2 Table MySql Query Assist
Something like
If not, it's something like that.
Code: Select all
SELECT X.*, Y.`Name` AS `Name`
FROM tbl1 X
INNER JOIN tbl2 Y ON X.`Catid`=Y.`ID`
GROUP BY tbl2.`Catid`
ORDER BY `Name` ASC