Forums

This topic is locked

Need some help with a SQL 2K query

Posted 10 Feb 2003 18:30:37
1
has voted
10 Feb 2003 18:30:37 Rip Munsterman posted:
I have a database with two tables in it. One is called mainmenus and the other is called submenus. The fields in the tables are as follows:

<b>MainMenus:</b> ID, PracticeID, MainMenu, MainMenuLink

<b>Submenus:</b> ID, PracticeID, Submenus, MML, MainMenuLink

Currently, mainmenus and submenus are connected by PracticeID and MainMenuLink. For example: (Select * from submenus where PracticeID = 1 and MainMenuLink = 2) would return all the submenus associate with the second mainmenu from Medical Practice #1. Each PracticeID starts a new count of MainMenuLinks (1, 2, 3, etc.)

Now, I want to just have a MML field in the submenus table that contains the ID field from the corresponding mainmenu. This will simplify things a lot more.

What I want to do is run a query in the SQL Query Analyzer that will basically say:

<font color=red>Update dbo.submenus
set submenus.MML = mainmenus.ID where mainmenus.PracticeID = submenus.PracticeID and mainmenus.mainmenulink = submenus.mainmenulink</font id=red>


Can anyone help me with the query I need to use? Thanks for any help in advance...

Rip

Reply to this topic