0

First off, I have no idea if this is possible, was just brainstorming.

I have a system that tracks 'live jobs' for a company's clients. They all get a unique 'job_id' in the database (Auto Incrementing).

Now these jobs have about 20+ tables linked to them (or will) and I have been naming columns in a certain pattern, to keep them easy to read.

All materials have a column called 'material_job_id', data files have a column called 'data_job_id' and so on for the various tables

What I was wondering is this:

Is it possible to delete ALL rows where the column ending in 'job_id' has the value X(Variable)

If nobody knows a relatively clean workaround, I'll just have to go into each table individually.

I also want to note, my knowledge of SQL is a bit limited, so if you know a way in SQL, I'd appreciate it if you explained what it was doing along the way

Any input is appreciated!

10
  • in case you use a DB like mysql - its maybe a good example for using a Trigger - stackoverflow.com/questions/11818191/… Commented Jan 16, 2017 at 12:12
  • 20+ is rather a lot - and can be symptomatic of poor design. Care to elaborate? Commented Jan 16, 2017 at 13:08
  • @sintakonte I'll take a look at that, thanks! Commented Jan 16, 2017 at 13:30
  • @Strawberry these jobs are in depth. however there are only 16, I just guessed how many off the top of my head. Commented Jan 16, 2017 at 13:37
  • 16, 20. Either way, it reeks of poor design. Commented Jan 16, 2017 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.