469,903 Members | 1,595 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Find & Delete Orphan Records

Have 2 tables
ts_sheets :
TimeSheet_ID
TimeSheet_Date
Emp_ID
Orphan

LineItem
TimeSheet_ID
Client
JobNumber etc

The following sql will show me all the ts_sheets records with
no ts_lineitem records

select s.* , l.timesheet_id
from ts_sheets s
left join ts_lineitem l on s.timesheet_id = l.timesheet_id
where l.timesheet_id is null

I would like to delete these orphan records
Something like

UPDATE `ts_sheets` SET `Orhan` = 'Yes'
left join ts_lineitem l on s.timesheet_id = l.timesheet_id
where l.timesheet_id is null

Than delete `Orhan` = 'Yes'

I can not work the syntax out

??
Jul 19 '05 #1
0 3486

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John Thorne | last post: by
3 posts views Thread by Tim Marshall | last post: by
2 posts views Thread by Mark Rae | last post: by
1 post views Thread by julian_m | last post: by
2 posts views Thread by julian_m | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.