sql help querying multiple database tables
I am joining a number of tables, mostly to retrieve descriptive information like names from related tables, and the simpler joins are working ok but where I am a little stuck is that I need to get project names from one database table if the value in a column called "type" is 1, and an entirely different table (in a different database) if the value in column "type" is 2. Not all records have an entry in the column, it is an optional column so there are nulls as well. I am a bit unsure of how to do it, I tried <CFIF> statements and also SQL case but couldn't get it to work. I was trying to use cfif to read the value in the column but it didn't seem to do it, I am not sure if I just got the syntax wrong or whether it can't be done this way. I really want to do this within the SQL query so that all the data is in one final table ready to display. I will also later need to count the number of 1s and 2s.
Can I do this with an if statement or is there another way? My code was along the lines of:
<cfif isNumeric("m.type") IS 2 >
