I've seen a few questions on here very similar to this however I have not found an answer specific to what I believe my problem to be.
I have two tables, subcompanies
and presets
. The two tables are linked together through an ID, CntRefID
and PresetIDFoxPro
. I want to select all of the text from the Preset
table's text column when the ID's matchup.
This works flawlessly when the CntRefID
has a number in it. However, if it is 0 then every single field from the presets
text column is returned instead.
This is my query text;
myQuery.CommandText =
"SELECT CompanyID, CompanyName, PresetText, InvHeader, Prefix, NextBnum
FROM sdcdatabase.sdcsubcompanies, sdcdatabase.presets
WHERE (CntRef=PresetIDFoxPro OR CntRef='0') AND PresetReferenceFoxPro=3";
I cannot get my head round why every field is selected. I have tried 0 in quotes and without quotes, I have also seen it could be due to one field being an Integer and one being a Char (mySQL returns all rows when field=0). Both my fields are integers however.