chiprivers Posted November 16, 2011 Share Posted November 16, 2011 I am struggling with a table join where the comparitive table fields are in different formats; one int and one var. I know that this is sloppy database construction but unfortunately it is not my database and I do not have any control over the table construction. In my query I have a join as below: SELECT ... ... FROM tableA LEFT JOIN tableB ON tableA.varField = tableB.intField Unfortunately this is not running because the datatypes in the fields that I am joining on are not the same datatype. Is there a function I can use to change the var value to an int before comparing it, or vice versa? I think from googling that I should be using cast() or convert() but I cannot find a clear explanation of these functions that has enabled me to workout if and how I could use either of these functions. Any help would be very much appreciated. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.