How can I delete only the elements in a joined table??

  • Thread starter Thread starter Mark Owert
  • Start date Start date
M

Mark Owert

I have


Table1: CodeArticle, name, quantity

Table2: CodeArticle, date


SELECT * FROM table1,table2 WHERE table1.quantity>10

AND Table1.CodeArticle=Table2.CodeArticle


Now, I want to delete only the elements in Table2

Thanks
 
Don't think you are going to get there with this structure. I'd try two
seperate SELECT statements into to seperate client side DataTablesa (say
Table1 and Table2) Add a DataRelation on Table1.CodeArticle ->
Table2.CodeArticle. Now you can just iterate through table 2 and delete
them.

I'm wondering though, if you are planning on submitting these changes to the
DB, I'd recommend handling this server side. No need to create two
datatables and a DataRelation, just to delete them locally and then submit
it to the DB in most instances.

However, I can tell you as a rule that will be valid most every time, don't
join tables on the DB and try to work with the joined set locally. Updates
will be difficult if not impossilbe, and you'll pull over data that will
probably be redundant depending on your query. Whatever the case, it'll
probably be much more of a pain than you'll want to deal with.

If you need any help, let me know.

Cheers,

B9ill
 
Back
Top