Hi Guys,

What is the way to compare two columns from different table?Say I want to compare column IDNumber from table 1 to column IDNumber to table 2, after that I want to delete Identical IdNumber and show the remaining unique IDNumber, any idea how to start it?

Recommended Answers

All 3 Replies

maybe it goes like this...

$sql = "SELECT * FROM table1 a
LEFT JOIN table2 b
ON a.IDNumber = b.IDNumber";
$qry = mysql_query($sql);
Member Avatar for diafol

OK let's assume that you want to delete all duplicates in table2

DELETE FROM table2 WHERE id IN (SELECT id FROM table1)

Thank You very much ardav and suhnako, I'll try your suggestion and update you for the result.

Good Day

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.