Friday, 15 April 2011

mysql - boolean column of values contained in another column - SQL -


In this page,

A user wants to include both in calling_ID which is called column call_ID. Suppose i have a column in two different tables, say

  table T1 calling_id 27 15 80 90 60 88 15 30 27 40  

and

  made the table T2_ID 10 20 90 88 30 40 60 40 9 30 30  

The second person results in the form of 90, 88, 30 and 40 I would like to - as a result a boolean column of this type

  in calling_id 27 0 15 0 80 0 90 1 60 0 88 1 15 0 30 1 27 0 40 0 ​​< / Code> 

How do I do this? Thanks a lot!

You can connect T1 to T2, and check whether ID is called or not NULL , Eg:

  SELECT Calling_ID, case when T2.Called_ID is T1 then T1 as T1 or T1 on T1 ON.Calling_ID = T2.Called_ID   

No comments:

Post a Comment