php - MySQL query for delete row if two columns are equal -
how delete rows mysql table if values of 2 columns equal
example table
invoice_id| item_id | name | invoiced_qty | received_qty --------------------------------------------------------- | 1 | 1 | item1 | 3 | 2 | 2 | 2 | item2 | 5 | 5 | 3 | 1 | item3 | 4 | 3 | 4 | 2 | item4 | 2 | 2 | 5 | 1 | item5 | 5 | 5
after deleting table needs retains
invoice_id| item_id | name | invoiced_qty | received_qty --------------------------------------------------------- | 1 | 1 | item1 | 3 | 2 | 3 | 1 | item3 | 4 | 3
the select query created is
select * table1 inner join table1 b on a.item_id = b.item_id , a.invoice_id = b.invoice_id , a.invoiced_qty = b.received_qty
thanks
why not sql fiddle:
delete table1 invoiced_qty = received_qty
your edit not change anything. sql fiddle demonstrating select query. according sample data a.invoice_id
never equal b.invoice_id
. not results.
Comments
Post a Comment