JCWEBHOST
asked on
sql join two tables
hey guys i have two table and need to join in one table using a select statement.
table one : menu
id
parent_id
title
table two: products
id
menu_id
name
my problem is the indentity in the id for bought table, so if they are enterd twice a erorr will oucur.
how can i fix the problem?
table one : menu
id
parent_id
title
table two: products
id
menu_id
name
my problem is the indentity in the id for bought table, so if they are enterd twice a erorr will oucur.
how can i fix the problem?
CREATE TABLE [dbo].[TableMenu](
[Id] [int] NOT NULL,
[ParentId] [int] NULL,
[Title] [nchar](20) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[TableProducts](
[Id] [int] NULL,
[Menu_Id] [int] NULL,
[Name] [nchar](20) NULL
) ON [PRIMARY]
GO
SELECT *
FROM TABLEMENU
SELECT *
FROM TABLEPRODUCTS
SELECT TM.ID,TITLE AS MAINMENU,
NAME AS SUBMENU
FROM TABLEMENU TM
LEFT
JOIN TABLEPRODUCTS TP
ON TM.ID = TP.MENU_ID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT Table1.ID, Table2.ID, etc...
FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.Menu_ID