Forum > Databases

[SOLVED] Comparing cells of two columns and show mismtaches - SQLite

(1/1)

Gizmo:
My program uses SQLite.

I have 4 columns in a DBGrid.

I want to compare Columns 2 and 4 and compare the strings in each, and where they don't match, I want to show the rows with the cells of all 4 columns.

I am using this, but it is showing me two columns, and more critically it is showing me all the values instead of just the few that do not match


--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TSQLQuery(DBGrid.DataSource.Dataset).SQL.Text := 'SELECT ColumnText2, ColumnText4 FROM TBL_MAINTABLE WHERE ColumnText2 <> ColumnText4';     
I'm fairly new to SQL overall so would value a pointer? Thanks

dseligo:
You should have all 4 columns in 'select' so they are in your result set:


--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TSQLQuery(DBGrid.DataSource.Dataset).SQL.Text := 'SELECT ColumnText1, ColumnText2, ColumnText3, ColumnText4 FROM TBL_MAINTABLE WHERE ColumnText2 <> ColumnText4';     

--- Quote ---and more critically it is showing me all the values instead of just the few that do not match

--- End quote ---

Your 'where' condition looks OK for what you've described.
Are you saying that ColumnText2 and ColumnText4 contain exactly the same data and are shown?
Maybe I didn't understand you, so can you give some example data?

Gizmo:
Missing the wood for trees again! Thank you sir. That has resolved the issue!

dseligo:
You're welcome, I'm glad it is solved

Navigation

[0] Message Index

Go to full version