Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete statement with condition from joined table

Status
Not open for further replies.

dolodolo

Technical User
May 27, 2003
86
US
Hi Guys,

I need help with the following statement. I am trying to delete records in one table (unitbut_amenity) based on a value in a joined table (unit):

delete from unitbut_amenity
inner join (select u.hproperty hproperty, u.hmy hunit from unit u) as main
on main.hunit = unitbut_amenity.hcode
where unitbut_amenity.notes1 = 'community-wide amenity' and main.hproperty = 983;

And getting the following errors:

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'inner'.
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'as'.

Any help is appreciated.

Thanks
 
delete unitbut_amenity from unitbut_amenity
inner join (select u.hproperty hproperty, u.hmy hunit from unit u) as main
on main.hunit = unitbut_amenity.hcode
where unitbut_amenity.notes1 = 'community-wide amenity' and main.hproperty = 983;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top