[SOLVED] Comparing cells of two columns and show mismtaches - SQLite lazarus / 16-Databases ---------------------------------------------------------------------- Gizmo · 2021-04-21 20:40 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  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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 · 2021-04-21 21:53 You should have all 4 columns in 'select' so they are in your result set: Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TSQLQuery(DBGrid.DataSource.Dataset).SQL.Text := 'SELECT ColumnText1, ColumnText2, ColumnText3, ColumnText4 FROM TBL_MAINTABLE WHERE ColumnText2 <> ColumnText4';   Quoteand more critically it is showing me all the values instead of just the few that do not match 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 · 2021-04-21 22:23 Missing the wood for trees again! Thank you sir. That has resolved the issue! ---------------------------------------------------------------------- dseligo · 2021-04-22 07:43 You're welcome, I'm glad it is solved