[thelist] Rookie SQL Question...

jsWalter jsWalter at torres.ws
Sun Aug 17 01:29:22 CDT 2003

I have 2 tables, menu_items, menu_type...

In menu_items is an identifier (m_type) that matches an identifier (m_type)
in menu_type (foreign key?).

I want to pull *everything* out of menu_items and have it sorted by its
'm_type' and then by its 'm_sort'.

Yes, the 'm_type' is populated in both tables.

What I have below returns nothing. It should return 50 records (test data)

	$strSql = 'SELECT * ';
	$strSql .= ' FROM menu_items, menu_type ';
	$strSql .= ' WHERE m_id = m_id' ;
	$strSql .= ' WHERE menu_items.m_type = menu_type.m_type ';
	$strSql .= ' ORDER BY menu_items.m_type, menu_items.m_sort ';

Where as this, returns all the rows, but replicated for each row in the
'menu_type' table.

Almost, but not quite what I'm looking for.

What I'm looking of is this...

   menu_items.m_id, menu_items.m_name, menu_items.m_sort, menu_items.m_type,



More information about the thelist mailing list