Hi how can compare two rows in two diffrent table and return the columns and his values that are not equal so for example i have table1 and table 2 that has column sum, and vehid , in table1 the sum = 20 and vehid = 1 while in table2 sum=20 and vehid = 2. so the output must return vehid as on those two table are not equal??
Is the sum sort of like an index? Will there be a unique sum for each row on each table, or will there be multiple rows will the same sums?
hmm no the sum is not an index.basically i want to compare 2 rows with same columns(number ,name) in 2 different table and return the column where its value didnt match each other?is there any way to do this?
When you say return the column where its value didn't match, do you just mean the two vehid values? So in the first example, you would just want to return 1 and 2?
yes i would like to get the output vehid then also output the values where they didnt have a match ex. vehid table1 value(1)=>table2 value(2) is not equal // as for sum will not be returned as they have the same value of 20, thats the gist of it, i really dont know whrere to start
Hi jigen7, I believe it is more of a SQL related query then PHP. However, a join query can solve your problem. Give a proper example to make it easy for making query. Following is the query based on my understanding: Select A.sum, B.sum, A.vahid, B.vahid, if(A.vahid = B.vahid, 1, 0) as compare_status from table1 A join table2 B on A.sum = B.sum compare_status will be 1 when vahid in both tables are equal, 0 otherwise. I presume that sum is not repeated in any table more than once else this query can give many to many result spoiling the output.