I'm trying to display some record from a database based on their ID. In this case, I would like to display the name (column2) based on the ID (column1) when I do a select query and I get this error.
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric
where id='1' and id in (select name from primar2)
I believe you're looking for an inner join;
SELECT t1.* ,t2.name FROM table1 t1 INNER JOIN table2 t2 ON t1.ID = t2.user_id WHERE p.id = '1'
This will give you everything from table1 that has a match in table2 and will return the name. Without seeing your schema I've taken a guess at the join field so this may need updating if necessary.