fruitbat Posted September 30, 2007 Report Share Posted September 30, 2007 Right, I am currently using and learning SQL and everything that goes along with it.Anyone on here pretty good with it as I need a little help with a statement I need to write?I have tried a couple of statements and they aren't working, any help greatly appreciatedReply here or PM meFrooty Quote Link to comment Share on other sites More sharing options...
tomturd Posted September 30, 2007 Report Share Posted September 30, 2007 I know a bit, whats your table structure and what are you trying to get out of it? Quote Link to comment Share on other sites More sharing options...
fruitbat Posted September 30, 2007 Author Report Share Posted September 30, 2007 I'll explain from the start so you know what i'm doingI have 2 tablesOne called tbl_jobs, another called tbl_outlet.tbl_outlet holds information about an Outlet, tbl_jobs holds information about all jobs relating to the outlets.Each holds different bits of information the only link between them is a column which is the OutletID number, which is unique for each record in tbl_outlet. The identity column in the jobs table has a JobID, which is again unique for each jobA collegue has been through the information and deleted any duplicate Outlets, so that there is only 1 OutletID for each outlet, but what he hasn't done is changed the OutletID in the tbl_jobs table to reflect this changeWhat I need to do is find all records in the tbl_jobs table, where there isn't a match to the OutletID in the tbl_outlet table (this will mean i can change the OutletID in the jobs table to match the change done in the Outlet table. Hope that made senseFrooty Quote Link to comment Share on other sites More sharing options...
Danny Posted September 30, 2007 Report Share Posted September 30, 2007 A quick and dirty way to do it would be something like this...SELECT * FROM tbl_jobs WHERE OutletID NOT IN (SELECT id FROM tbl_outlet)where 'id' is whatever the column that OutletID ties to is called. Quote Link to comment Share on other sites More sharing options...
Dai the Socket Posted September 30, 2007 Report Share Posted September 30, 2007 A quick and dirty way to do it would be something like this...You're good at dirty code aren't you :P Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.