Recent

Author Topic: [SOLVED] Comparing cells of two columns and show mismtaches - SQLite  (Read 1054 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
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][+][-]
  1. TSQLQuery(DBGrid.DataSource.Dataset).SQL.Text := 'SELECT ColumnText2, ColumnText4 FROM TBL_MAINTABLE WHERE ColumnText2 <> ColumnText4';    
  2.  

I'm fairly new to SQL overall so would value a pointer? Thanks
« Last Edit: April 22, 2021, 12:23:23 am by Gizmo »

dseligo

  • Hero Member
  • *****
  • Posts: 1196
Re: Comparing cells of two columns and show mismtaches - SQLite
« Reply #1 on: April 21, 2021, 11:53:07 pm »
You should have all 4 columns in 'select' so they are in your result set:

Code: SQL  [Select][+][-]
  1. TSQLQuery(DBGrid.DataSource.Dataset).SQL.Text := 'SELECT ColumnText1, ColumnText2, ColumnText3, ColumnText4 FROM TBL_MAINTABLE WHERE ColumnText2 <> ColumnText4';    
  2.  

Quote
and 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?
« Last Edit: April 21, 2021, 11:55:30 pm by dseligo »

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: [SOLVED] Comparing cells of two columns and show mismtaches - SQLite
« Reply #2 on: April 22, 2021, 12:23:50 am »
Missing the wood for trees again! Thank you sir. That has resolved the issue!

dseligo

  • Hero Member
  • *****
  • Posts: 1196
Re: [SOLVED] Comparing cells of two columns and show mismtaches - SQLite
« Reply #3 on: April 22, 2021, 09:43:38 am »
You're welcome, I'm glad it is solved

 

TinyPortal © 2005-2018